setInvalid() functions added.
authoralpar
Wed, 25 Feb 2004 15:26:39 +0000
changeset 1291630a5b631c8
parent 128 f3511cffee11
child 130 571003783202
setInvalid() functions added.
src/work/alpar/smart_graph.h
     1.1 --- a/src/work/alpar/smart_graph.h	Wed Feb 25 12:11:28 2004 +0000
     1.2 +++ b/src/work/alpar/smart_graph.h	Wed Feb 25 15:26:39 2004 +0000
     1.3 @@ -5,26 +5,29 @@
     1.4  
     1.5  #include <iostream>
     1.6  #include <vector>
     1.7 +#include <limits.h>
     1.8  
     1.9  namespace hugo {
    1.10  
    1.11    class SmartGraph {
    1.12  
    1.13 -    static const int INVALID=-1;
    1.14 +    static const int INVALID_EDGE=-1;
    1.15 +    static const int INVALID_NODE=INT_MAX;
    1.16  
    1.17      struct NodeT 
    1.18      {
    1.19        int first_in,first_out;      
    1.20 -      NodeT() : first_in(INVALID), first_out(INVALID) {}
    1.21 +      NodeT() : first_in(INVALID_EDGE), first_out(INVALID_EDGE) {}
    1.22      };
    1.23      struct EdgeT 
    1.24      {
    1.25        int head, tail, next_in, next_out;      
    1.26        //FIXME: is this necessary?
    1.27 -      EdgeT() : next_in(INVALID), next_out(INVALID) {}  
    1.28 +      EdgeT() : next_in(INVALID_EDGE), next_out(INVALID_EDGE) {}  
    1.29      };
    1.30  
    1.31      std::vector<NodeT> nodes;
    1.32 +
    1.33      std::vector<EdgeT> edges;
    1.34      
    1.35      template <typename Key> class DynMapBase
    1.36 @@ -123,10 +126,13 @@
    1.37        return e; 
    1.38      }
    1.39  
    1.40 -    bool valid(EdgeIt e) const { return e.n!=INVALID; }
    1.41 +    bool valid(EdgeIt e) const { return e.n!=INVALID_EDGE; }
    1.42      bool valid(EachEdgeIt e) const { return e.n<int(edges.size()); }
    1.43      bool valid(NodeIt n) const { return n.n<int(nodes.size()); }
    1.44      
    1.45 +    void setInvalid(EdgeIt &e) { e.n=INVALID_EDGE; }
    1.46 +    void setInvalid(NodeIt &e) { e.n=INVALID_NODE; }
    1.47 +    
    1.48      template <typename It> It next(It it) const
    1.49        //    { It tmp(it); return goNext(tmp); }
    1.50      { It tmp; tmp.n=it.n+1; return tmp; }