00001 #ifndef NODEARRAY_H
00002 #define NODEARRAY_H
00003
00004 #include <Structs/Graphs/dynamicGraph.h>
00005 #include <Structs/Maps/pmMap.h>
00006
00007
00008 template< typename dataType, typename GraphType>
00009 class NodeArray
00010 {
00011 public:
00012
00013 typedef GraphType Graph;
00014 typedef typename Graph::NodeIterator node;
00015 typedef typename Graph::SizeType sizeType;
00016
00017 NodeArray():m_G(0)
00018 {
00019 }
00020
00021 NodeArray( const Graph* G, dataType data = dataType()):m_G(G)
00022 {
00023 init(G, data);
00024 }
00025
00026 ~NodeArray()
00027 {
00028 }
00029
00030 void init( const Graph* G, dataType data = dataType())
00031 {
00032 m_map.clear();
00033 m_G = G;
00034
00035 node u, end;
00036 for( u = G->beginNodes(), end = G->endNodes(); u != end; ++u)
00037 {
00038 m_map[u->getDescriptor()] = data;
00039 }
00040 }
00041
00042 dataType& operator[] ( const node& u )
00043 {
00044 return m_map[ u->getDescriptor()];
00045 }
00046
00047 const dataType& operator[] ( const node& u ) const
00048 {
00049 return m_map[ u->getDescriptor()];
00050 }
00051
00052 private:
00053 const GraphType* m_G;
00054 PMMap< typename GraphType::NodeDescriptor, dataType> m_map;
00055 };
00056
00057
00058
00059 #endif //NODEARRAY_H