1.1 --- a/src/include/graph.h Mon Dec 15 17:46:22 2003 +0000
1.2 +++ b/src/include/graph.h Tue Dec 16 16:19:08 2003 +0000
1.3 @@ -4,6 +4,7 @@
1.4
1.5 //inline void *operator new(size_t s, void *p) { return p; }
1.6 #include <new>
1.7 +#include <vector>
1.8
1.9 namespace NEGRO
1.10 {
1.11 @@ -40,7 +41,7 @@
1.12 class SymEdgeIterator;
1.13 class AllEdgeIterator;
1.14
1.15 - class FirstAnythingTypeNode;
1.16 + class FirstAnythingTypeNode; //Required by the unified First() function.
1.17
1.18 friend class NodeIterator;
1.19 friend class EdgeIterator;
1.20 @@ -391,6 +392,45 @@
1.21 void Clean() { OldGraph<N,E>::Clean(); }
1.22
1.23 Graph() : _FST(this) {}
1.24 +
1.25 + // MAPS:
1.26 + template<class T> class NodeMap
1.27 + {
1.28 + Graph<N,E> *G;
1.29 + vector<T> map;
1.30 +
1.31 + public:
1.32 + typedef T value_type;
1.33 + void Set(NodeIterator i, const T &t) {map[i.Index()]=t;}
1.34 + T &Get(NodeIterator i) {return map[i.Index()];}
1.35 + T &operator[](NodeIterator i) {return map[i.Index()];}
1.36 +
1.37 + void update() { map.resize(G->OldGraph<N,E>::NodeMax());}
1.38 +
1.39 + NodeMap(Graph<N,E> &Gr) : map(Gr.OldGraph<N,E>::NodeMax()) { G=&Gr ;}
1.40 +
1.41 + };
1.42 +
1.43 + template<class T> class EdgeMap
1.44 + {
1.45 + Graph<N,E> *G;
1.46 + vector<T> map;
1.47 +
1.48 + public:
1.49 + typedef T value_type;
1.50 + void Set(NodeIterator i, const T &t) {map[i.Index()]=t;}
1.51 + T &Get(NodeIterator i) {return map[i.Index()];}
1.52 + T &operator[](NodeIterator i) {return map[i.Index()];}
1.53 +
1.54 + void update()
1.55 + { map.resize(Gr.OldGraph<N,E>::edge_block_num*EDGE_BLOCK_SIZE);}
1.56 +
1.57 + EdgeMap(Graph<N,E> &Gr)
1.58 + :map(Gr.OldGraph<N,E>::edge_block_num*EDGE_BLOCK_SIZE)
1.59 + { G=&Gr ;}
1.60 +
1.61 + };
1.62 +
1.63 };
1.64
1.65 /* Ez itt a fiam kommentje: