Changeset 786:d7b3b13b9df6 in lemon-0.x for src
- Timestamp:
- 09/02/04 17:21:13 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1079
- Location:
- src/hugo
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/hugo/array_map_factory.h
r785 r786 23 23 24 24 typedef typename MapRegistry::Graph Graph; 25 typedef typename MapRegistry::Key Key;25 typedef typename MapRegistry::KeyType KeyType; 26 26 typedef typename MapRegistry::KeyIt KeyIt; 27 27 … … 114 114 115 115 116 Value& operator[](const Key & key) {116 Value& operator[](const KeyType& key) { 117 117 int id = MapBase::getGraph()->id(key); 118 118 return values[id]; 119 119 } 120 120 121 const Value& operator[](const Key & key) const {121 const Value& operator[](const KeyType& key) const { 122 122 int id = MapBase::getGraph()->id(key); 123 123 return values[id]; 124 124 } 125 125 126 const Value& get(const Key & key) const {126 const Value& get(const KeyType& key) const { 127 127 int id = MapBase::getGraph()->id(key); 128 128 return values[id]; 129 129 } 130 130 131 void set(const Key & key, const Value& val) {131 void set(const KeyType& key, const Value& val) { 132 132 int id = MapBase::getGraph()->id(key); 133 133 values[id] = val; 134 134 } 135 135 136 void add(const Key & key) {136 void add(const KeyType& key) { 137 137 int id = MapBase::getGraph()->id(key); 138 138 if (id >= capacity) { … … 156 156 } 157 157 158 void erase(const Key & key) {158 void erase(const KeyType& key) { 159 159 int id = MapBase::getGraph()->id(key); 160 160 allocator.destroy(&(values[id])); … … 185 185 iterator() {} 186 186 187 typedef extended_pair<const Key &, const Key&,187 typedef extended_pair<const KeyType&, const KeyType&, 188 188 Value&, Value&> Reference; 189 189 … … 198 198 private: 199 199 Reference data; 200 Pointer(const Key & key, Value& val) : data(key, val) {}200 Pointer(const KeyType& key, Value& val) : data(key, val) {} 201 201 public: 202 202 Reference* operator->() {return &data;} … … 275 275 const_iterator(iterator p_it) : map(p_it.map), it(p_it.it) {} 276 276 277 typedef extended_pair<const Key &, const Key&,277 typedef extended_pair<const KeyType&, const KeyType&, 278 278 const Value&, const Value&> Reference; 279 279 … … 289 289 private: 290 290 Reference data; 291 Pointer(const Key & key, const Value& val) : data(key, val) {}291 Pointer(const KeyType& key, const Value& val) : data(key, val) {} 292 292 public: 293 293 Reference* operator->() {return &data;} -
src/hugo/map_registry.h
r785 r786 26 26 public: 27 27 typedef G Graph; 28 typedef K Key ;28 typedef K KeyType; 29 29 typedef KIt KeyIt; 30 30 … … 39 39 public: 40 40 typedef G Graph; 41 typedef K Key ;41 typedef K KeyType; 42 42 typedef KIt KeyIt; 43 43 … … 136 136 */ 137 137 138 virtual void add(const Key &) = 0;138 virtual void add(const KeyType&) = 0; 139 139 /** 140 140 The erase member function should be overloaded in the subclasses. … … 142 142 */ 143 143 144 virtual void erase(const Key &) = 0;144 virtual void erase(const KeyType&) = 0; 145 145 146 146 /** … … 241 241 * Notify all the registered maps about a Key added. 242 242 */ 243 void add(Key & key) {243 void add(KeyType& key) { 244 244 typename Container::iterator it; 245 245 for (it = container.begin(); it != container.end(); ++it) { … … 251 251 * Notify all the registered maps about a Key erased. 252 252 */ 253 void erase(Key & key) {253 void erase(KeyType& key) { 254 254 typename Container::iterator it; 255 255 for (it = container.begin(); it != container.end(); ++it) { -
src/hugo/sym_map_factory.h
r782 r786 36 36 37 37 typedef typename MapRegistry::Graph Graph; 38 typedef typename MapRegistry::Key Key;38 typedef typename MapRegistry::KeyType KeyType; 39 39 typedef typename MapRegistry::KeyIt KeyIt; 40 40 … … 69 69 } 70 70 71 Value& operator[](const Key & key) {71 Value& operator[](const KeyType& key) { 72 72 int id = MapBase::getGraph()->id(key); 73 73 return MapImpl::operator[](id >> 1); 74 74 } 75 75 76 const Value& operator[](const Key & key) const {76 const Value& operator[](const KeyType& key) const { 77 77 int id = MapBase::getGraph()->id(key); 78 78 return MapImpl::operator[](id >> 1); 79 79 } 80 80 81 const Value& get(const Key & key) const {81 const Value& get(const KeyType& key) const { 82 82 int id = MapBase::getGraph()->id(key); 83 83 return MapImpl::operator[](id >> 1); 84 84 } 85 85 86 void set(const Key & key, const Value& val) {86 void set(const KeyType& key, const Value& val) { 87 87 int id = MapBase::getGraph()->id(key); 88 88 MapImpl::operator[](id >> 1) = val; 89 89 } 90 90 91 void add(const Key & key) {91 void add(const KeyType& key) { 92 92 int id = MapBase::getGraph()->id(key); 93 93 if (id & 1) return; … … 95 95 } 96 96 97 void erase(const Key & key) {97 void erase(const KeyType& key) { 98 98 int id = MapBase::getGraph()->id(key); 99 99 if (id & 1) return; -
src/hugo/vector_map_factory.h
r785 r786 31 31 typedef typename MapRegistry::Graph Graph; 32 32 /// The key type of the maps. 33 typedef typename MapRegistry::Key Key;33 typedef typename MapRegistry::KeyType KeyType; 34 34 /// The iterator to iterate on the keys. 35 35 typedef typename MapRegistry::KeyIt KeyIt; … … 113 113 * actual keys of the graph. 114 114 */ 115 typename Container::reference operator[](const Key & key) {115 typename Container::reference operator[](const KeyType& key) { 116 116 int id = getGraph()->id(key); 117 117 return container[id]; … … 122 122 * actual keys of the graph. 123 123 */ 124 typename Container::const_reference operator[](const Key & key) const {124 typename Container::const_reference operator[](const KeyType& key) const { 125 125 int id = getGraph()->id(key); 126 126 return container[id]; … … 130 130 * This is a compatibility feature with the not dereferable maps. 131 131 */ 132 void set(const Key & key, const Value& val) {132 void set(const KeyType& key, const Value& val) { 133 133 int id = getGraph()->id(key); 134 134 container[id] = val; … … 137 137 /** Add a new key to the map. It called by the map registry. 138 138 */ 139 void add(const Key & key) {139 void add(const KeyType& key) { 140 140 int id = getGraph()->id(key); 141 141 if (id >= container.size()) { … … 146 146 /** Erase a key from the map. It called by the map registry. 147 147 */ 148 void erase(const Key & key) {}148 void erase(const KeyType& key) {} 149 149 150 150 /** Clear the data structure. … … 173 173 iterator() {} 174 174 175 typedef extended_pair<const Key &, const Key&,175 typedef extended_pair<const KeyType&, const KeyType&, 176 176 Value&, Value&> Reference; 177 177 … … 186 186 private: 187 187 Reference data; 188 Pointer(const Key & key, Value& val) : data(key, val) {}188 Pointer(const KeyType& key, Value& val) : data(key, val) {} 189 189 public: 190 190 Reference* operator->() {return &data;} … … 263 263 const_iterator(iterator p_it) : map(p_it.map), it(p_it.it) {} 264 264 265 typedef extended_pair<const Key &, const Key&,265 typedef extended_pair<const KeyType&, const KeyType&, 266 266 const Value&, const Value&> Reference; 267 267 … … 277 277 private: 278 278 Reference data; 279 Pointer(const Key & key, const Value& val) : data(key, val) {}279 Pointer(const KeyType& key, const Value& val) : data(key, val) {} 280 280 public: 281 281 Reference* operator->() {return &data;}
Note: See TracChangeset
for help on using the changeset viewer.