Changeset 698:625de6f1e766 in lemon-0.x for src/work/deba/vector_map_factory.h
- Timestamp:
- 07/09/04 09:33:12 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@949
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/deba/vector_map_factory.h
r627 r698 4 4 #include <vector> 5 5 6 #include "map_registry.h"7 8 6 namespace hugo { 9 7 10 8 template <typename MapRegistry> 11 class VectorMapFactory {12 public:9 class VectorMapFactory { 10 public: 13 11 14 12 typedef typename MapRegistry::Graph Graph; … … 17 15 18 16 typedef typename MapRegistry::MapBase MapBase; 17 19 18 20 19 template <typename V> … … 23 22 typedef V Value; 24 23 24 typedef std::vector<Value> Container; 25 25 Map() {} 26 26 … … 35 35 36 36 37 Value&operator[](const Key& key) {37 typename Container::reference operator[](const Key& key) { 38 38 int id = graph->id(key); 39 39 return container[id]; 40 40 } 41 41 42 const Value&operator[](const Key& key) const {42 typename Container::const_reference operator[](const Key& key) const { 43 43 int id = graph->id(key); 44 44 return container[id]; 45 45 } 46 46 47 const Value& get(const Key& key) const {48 int id = graph->id(key);49 return container[id];50 }51 52 47 void set(const Key& key, const Value& val) { 53 48 int id = graph->id(key); … … 64 59 void erase(const Key& key) {} 65 60 61 class const_iterator { 62 63 private: 64 65 }; 66 67 class iterator { 68 public: 69 iterator() {} 70 71 std::pair<const Key&, Value&> operator*() { 72 return std::pair<const Key&, Value&>(static_cast<Key&>(it), map[it]); 73 } 74 75 iterator& operator++() { ++it; return *this; } 76 iterator operator++(int) { iterator tmp(it); ++it; return tmp; } 77 private: 78 Map& map; 79 KeyIt it; 80 }; 81 66 82 private: 67 83 typedef std::vector<Value> Container; 68 84 69 85 Container container; 86 87 70 88 }; 89 90 91 71 92 72 93 };
Note: See TracChangeset
for help on using the changeset viewer.