8 template <typename MapRegistry>
9 class VectorMapFactory {
12 typedef typename MapRegistry::Graph Graph;
13 typedef typename MapRegistry::Key Key;
14 typedef typename MapRegistry::KeyIt KeyIt;
16 typedef typename MapRegistry::MapBase MapBase;
20 class Map : public MapBase {
24 typedef std::vector<Value> Container;
27 Map(Graph& g, MapRegistry& r) : MapBase(g, r) {
37 typename Container::reference operator[](const Key& key) {
38 int id = graph->id(key);
42 typename Container::const_reference operator[](const Key& key) const {
43 int id = graph->id(key);
47 void set(const Key& key, const Value& val) {
48 int id = graph->id(key);
52 void add(const Key& key) {
53 int id = graph->id(key);
54 if (id >= container.size()) {
55 container.resize(id + 1);
59 void erase(const Key& key) {}
61 class const_iterator {
71 std::pair<const Key&, Value&> operator*() {
72 return std::pair<const Key&, Value&>(static_cast<Key&>(it), map[it]);
75 iterator& operator++() { ++it; return *this; }
76 iterator operator++(int) { iterator tmp(it); ++it; return tmp; }
83 typedef std::vector<Value> Container;