diff -r f5852ebe00ca -r b63d1bc367f7 src/include/graph.h --- a/src/include/graph.h Mon Dec 15 17:46:22 2003 +0000 +++ b/src/include/graph.h Tue Dec 16 16:19:08 2003 +0000 @@ -4,6 +4,7 @@ //inline void *operator new(size_t s, void *p) { return p; } #include +#include namespace NEGRO { @@ -40,7 +41,7 @@ class SymEdgeIterator; class AllEdgeIterator; - class FirstAnythingTypeNode; + class FirstAnythingTypeNode; //Required by the unified First() function. friend class NodeIterator; friend class EdgeIterator; @@ -391,6 +392,45 @@ void Clean() { OldGraph::Clean(); } Graph() : _FST(this) {} + + // MAPS: + template class NodeMap + { + Graph *G; + vector map; + + public: + typedef T value_type; + void Set(NodeIterator i, const T &t) {map[i.Index()]=t;} + T &Get(NodeIterator i) {return map[i.Index()];} + T &operator[](NodeIterator i) {return map[i.Index()];} + + void update() { map.resize(G->OldGraph::NodeMax());} + + NodeMap(Graph &Gr) : map(Gr.OldGraph::NodeMax()) { G=&Gr ;} + + }; + + template class EdgeMap + { + Graph *G; + vector map; + + public: + typedef T value_type; + void Set(NodeIterator i, const T &t) {map[i.Index()]=t;} + T &Get(NodeIterator i) {return map[i.Index()];} + T &operator[](NodeIterator i) {return map[i.Index()];} + + void update() + { map.resize(Gr.OldGraph::edge_block_num*EDGE_BLOCK_SIZE);} + + EdgeMap(Graph &Gr) + :map(Gr.OldGraph::edge_block_num*EDGE_BLOCK_SIZE) + { G=&Gr ;} + + }; + }; /* Ez itt a fiam kommentje: