deba@571: #ifndef VECTOR_MAP_H deba@571: #define VECTOR_MAP_H deba@571: deba@571: #include deba@571: #include deba@571: deba@571: #include "map_base.h" deba@571: deba@571: namespace hugo { deba@571: deba@571: template deba@571: class VectorMapFactory { deba@571: deba@571: deba@571: public: deba@571: deba@571: typedef G Graph; deba@571: typedef K Key; deba@571: typedef KIt KeyIt; deba@571: deba@571: template deba@571: class VectorMap : public MapBase { deba@571: public: deba@571: typedef V ValueType; deba@571: deba@571: VectorMap() {} deba@571: deba@571: VectorMap(Graph& g, MapRegistry& r) deba@571: : MapBase(g, r) {} deba@571: deba@571: deba@571: ValueType& operator[](const K& key) { deba@571: int id = graph->id(key); deba@571: return container[id]; deba@571: } deba@571: deba@571: const ValueType& operator[](const K& key) const { deba@571: int id = graph->id(key); deba@571: return container[id]; deba@571: } deba@571: deba@571: const ValueType& get(const K& key) const { deba@571: int id = graph->id(key); deba@571: return container[id]; deba@571: } deba@571: deba@571: void set(const K& key, const ValueType& val) { deba@571: int id = graph->id(key); deba@571: container[id] = val; deba@571: } deba@571: deba@571: void add(const K& key) { deba@571: int id = graph->id(key); deba@571: std::cerr << id << std::endl; deba@571: if (id >= container.size()) { deba@571: container.resize(id + 1); deba@571: } deba@571: } deba@571: deba@571: void erase(const K& key) {} deba@571: deba@571: private: deba@571: typedef std::vector Container; deba@571: deba@571: Container container; deba@571: }; deba@571: deba@571: }; deba@571: } deba@571: deba@571: #endif