| Line |   | 
|---|
| 1 | #ifndef VECTOR_MAP_H | 
|---|
| 2 | #define VECTOR_MAP_H | 
|---|
| 3 |  | 
|---|
| 4 | #include <vector> | 
|---|
| 5 | #include <iostream> | 
|---|
| 6 |  | 
|---|
| 7 | #include "map_base.h" | 
|---|
| 8 |  | 
|---|
| 9 | namespace hugo { | 
|---|
| 10 |  | 
|---|
| 11 |         template <typename G, typename K, typename KIt, typename V>  | 
|---|
| 12 |         class VectorMap : public MapBase<G, K, KIt> { | 
|---|
| 13 |         public: | 
|---|
| 14 |                 typedef V ValueType; | 
|---|
| 15 |          | 
|---|
| 16 |                 VectorMap() {} | 
|---|
| 17 |                 VectorMap(typename MapBase<G, K, KIt>::Registry& r) : MapBase<G, K, KIt>(r) {} | 
|---|
| 18 |          | 
|---|
| 19 |          | 
|---|
| 20 |                 ValueType& operator[](const K& key) { | 
|---|
| 21 |                         int id = registry->getGraph().id(key); | 
|---|
| 22 |                         return container[id]; | 
|---|
| 23 |                 }  | 
|---|
| 24 |          | 
|---|
| 25 |                 const ValueType& operator[](const K& key) const { | 
|---|
| 26 |                         int id = registry->getGraph().id(key); | 
|---|
| 27 |                         return container[id]; | 
|---|
| 28 |                 } | 
|---|
| 29 |          | 
|---|
| 30 |                 const ValueType& get(const K& key) const { | 
|---|
| 31 |                         int id = registry->getGraph().id(key); | 
|---|
| 32 |                         return container[id]; | 
|---|
| 33 |                 }  | 
|---|
| 34 |          | 
|---|
| 35 |                 void set(const K& key, const ValueType& val) { | 
|---|
| 36 |                         int id = registry->getGraph().id(key); | 
|---|
| 37 |                         container[id] = val; | 
|---|
| 38 |                 } | 
|---|
| 39 |          | 
|---|
| 40 |                 void add(const K& key) { | 
|---|
| 41 |                         int id = registry->getGraph().id(key); | 
|---|
| 42 |                         std::cerr << id << std::endl; | 
|---|
| 43 |                         if (id >= container.size()) { | 
|---|
| 44 |                                 container.resize(id + 1); | 
|---|
| 45 |                         } | 
|---|
| 46 |                 } | 
|---|
| 47 |          | 
|---|
| 48 |                 void erase(const K& key) {} | 
|---|
| 49 |  | 
|---|
| 50 |         private: | 
|---|
| 51 |                 typedef std::vector<ValueType> Container; | 
|---|
| 52 |          | 
|---|
| 53 |                 Container container; | 
|---|
| 54 |         }; | 
|---|
| 55 |  | 
|---|
| 56 | } | 
|---|
| 57 |  | 
|---|
| 58 | #endif | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.