src/work/deba/vector_map_factory.h
changeset 702 4207f82a1778
parent 700 236117f60eee
child 703 32f280a5ed7d
equal deleted inserted replaced
4:9337f75f55ee 5:953fb109bdf3
     1 #ifndef VECTOR_MAP_H
     1 #ifndef VECTOR_MAP_H
     2 #define VECTOR_MAP_H
     2 #define VECTOR_MAP_H
     3 
     3 
     4 #include <vector>
     4 #include <vector>
     5 #include <iostream>
     5 #include <iostream>
       
     6 
       
     7 #include "extended_pair.h"
     6 
     8 
     7 namespace hugo {
     9 namespace hugo {
     8 
    10 
     9   /** The VectorMapFactory template class is a factory class
    11   /** The VectorMapFactory template class is a factory class
    10    *  to create maps for the edge and nodes. This map factory
    12    *  to create maps for the edge and nodes. This map factory
   153 	 */	 
   155 	 */	 
   154 	std::pair<const Key, Value> operator*() {
   156 	std::pair<const Key, Value> operator*() {
   155 	  return std::pair<const Key, Value>(it, (*map)[it]);
   157 	  return std::pair<const Key, Value>(it, (*map)[it]);
   156 	}
   158 	}
   157 
   159 
       
   160 
       
   161 	class Pointer {
       
   162 	  friend class iterator;
       
   163 	private:
       
   164 	  typedef extended_pair<const Key&, const Key&, Value&, Value&> Pair;
       
   165 	  Pair data;
       
   166 	  Pointer(const Key& key, Value& val) : data(key, val) {}
       
   167 	public:
       
   168 	  Pair* operator->() {return &data;}
       
   169 	};
       
   170 
   158 	/** Arrow operator for map.
   171 	/** Arrow operator for map.
   159 	 */	 
   172 	 */	 
   160 	std::pair<const Key, Value>* operator->() {
   173 	Pointer operator->() {
   161 	  static std::pair<const Key, Value> tmp = operator*();
   174 	  return Pointer(it, ((*map)[it])); 
   162 	  return &tmp;
       
   163 	}
   175 	}
   164 
   176 
   165 	/** The pre increment operator of the map.
   177 	/** The pre increment operator of the map.
   166 	 */
   178 	 */
   167 	iterator& operator++() { 
   179 	iterator& operator++() { 
   186 	/** The not-equality operator of the map.
   198 	/** The not-equality operator of the map.
   187 	 */
   199 	 */
   188 	bool operator!=(const_iterator p_it) {
   200 	bool operator!=(const_iterator p_it) {
   189 	  return !(*this == p_it);
   201 	  return !(*this == p_it);
   190 	}
   202 	}
       
   203 
   191 	
   204 	
   192       private:
   205       private:
   193 	Map* map;
   206 	Map* map;
   194 	KeyIt it;
   207 	KeyIt it;
   195       };
   208       };
   232 	 */	 
   245 	 */	 
   233 	std::pair<const Key, const Value> operator*() const {
   246 	std::pair<const Key, const Value> operator*() const {
   234 	  return std::pair<const Key, const Value>(it, (*map)[it]);
   247 	  return std::pair<const Key, const Value>(it, (*map)[it]);
   235 	}
   248 	}
   236 
   249 
       
   250 	class Pointer {
       
   251 	  friend class const_iterator;
       
   252 	private:
       
   253 	  typedef extended_pair<const Key&, const Key&, const Value&, const Value&> Pair;
       
   254 	  Pair data;
       
   255 	  Pointer(const Key& key, const Value& val) : data(key, val) {}
       
   256 	public:
       
   257 	  Pair* operator->() {return &data;}
       
   258 	};
   237 	/** Arrow operator for map.
   259 	/** Arrow operator for map.
   238 	 */	 
   260 	 */	 
   239 	std::pair<const Key, const Value>* operator->() const {
   261 	Pointer operator->() const {
   240 	  static std::pair<const Key, const Value> tmp = operator*();
   262 	  return Pointer(it, (*map)[it]);
   241 	  return &tmp;
       
   242 	}
   263 	}
   243 
   264 
   244 	/** The pre increment operator of the map.
   265 	/** The pre increment operator of the map.
   245 	 */
   266 	 */
   246 	const_iterator& operator++() { 
   267 	const_iterator& operator++() { 
   266 	 */
   287 	 */
   267 	bool operator!=(const_iterator p_it) {
   288 	bool operator!=(const_iterator p_it) {
   268 	  return !(*this == p_it);
   289 	  return !(*this == p_it);
   269 	}
   290 	}
   270 	
   291 	
       
   292 
   271       private:
   293       private:
   272 	const Map* map;
   294 	const Map* map;
   273 	KeyIt it;
   295 	KeyIt it;
   274       };
   296       };
   275 
   297