69 /// The container type of the map. |
69 /// The container type of the map. |
70 typedef std::vector<Value> Container; |
70 typedef std::vector<Value> Container; |
71 |
71 |
72 public: |
72 public: |
73 |
73 |
74 /// The value type of the map. |
|
75 typedef Value ValueType; |
|
76 /// The reference type of the map; |
74 /// The reference type of the map; |
77 typedef typename Container::reference ReferenceType; |
75 typedef typename Container::reference Reference; |
78 /// The pointer type of the map; |
76 /// The pointer type of the map; |
79 typedef typename Container::pointer PointerType; |
77 typedef typename Container::pointer Pointer; |
80 |
78 |
81 /// The const value type of the map. |
79 /// The const value type of the map. |
82 typedef const Value ConstValueType; |
80 typedef const Value ConstValue; |
83 /// The const reference type of the map; |
81 /// The const reference type of the map; |
84 typedef typename Container::const_reference ConstReferenceType; |
82 typedef typename Container::const_reference ConstReference; |
85 /// The pointer type of the map; |
83 /// The pointer type of the map; |
86 typedef typename Container::const_pointer ConstPointerType; |
84 typedef typename Container::const_pointer ConstPointer; |
87 |
85 |
88 /// Constructor to attach the new map into the registry. |
86 /// Constructor to attach the new map into the registry. |
89 |
87 |
90 /// It construates a map and attachs it into the registry. |
88 /// It construates a map and attachs it into the registry. |
91 /// It adds all the items of the graph to the map. |
89 /// It adds all the items of the graph to the map. |
148 /// The subcript operator. |
146 /// The subcript operator. |
149 |
147 |
150 /// The subscript operator. The map can be subscripted by the |
148 /// The subscript operator. The map can be subscripted by the |
151 /// actual items of the graph. |
149 /// actual items of the graph. |
152 |
150 |
153 ReferenceType operator[](const KeyType& key) { |
151 Reference operator[](const Key& key) { |
154 return container[graph->id(key)]; |
152 return container[graph->id(key)]; |
155 } |
153 } |
156 |
154 |
157 /// The const subcript operator. |
155 /// The const subcript operator. |
158 |
156 |
159 /// The const subscript operator. The map can be subscripted by the |
157 /// The const subscript operator. The map can be subscripted by the |
160 /// actual items of the graph. |
158 /// actual items of the graph. |
161 |
159 |
162 ConstReferenceType operator[](const KeyType& key) const { |
160 ConstReference operator[](const Key& key) const { |
163 return container[graph->id(key)]; |
161 return container[graph->id(key)]; |
164 } |
162 } |
165 |
163 |
166 |
164 |
167 /// The setter function of the map. |
165 /// The setter function of the map. |
168 |
166 |
169 /// It the same as operator[](key) = value expression. |
167 /// It the same as operator[](key) = value expression. |
170 /// |
168 /// |
171 |
169 |
172 void set(const KeyType& key, const ValueType& value) { |
170 void set(const Key& key, const Value& value) { |
173 (*this)[key] = value; |
171 (*this)[key] = value; |
174 } |
172 } |
175 |
173 |
176 /// Adds a new key to the map. |
174 /// Adds a new key to the map. |
177 |
175 |
178 /// It adds a new key to the map. It called by the observer registry |
176 /// It adds a new key to the map. It called by the observer registry |
179 /// and it overrides the add() member function of the observer base. |
177 /// and it overrides the add() member function of the observer base. |
180 |
178 |
181 void add(const KeyType& key) { |
179 void add(const Key& key) { |
182 int id = graph->id(key); |
180 int id = graph->id(key); |
183 if (id >= (int)container.size()) { |
181 if (id >= (int)container.size()) { |
184 container.resize(id + 1); |
182 container.resize(id + 1); |
185 } |
183 } |
186 } |
184 } |
187 |
185 |
188 /// Erases a key from the map. |
186 /// Erases a key from the map. |
189 |
187 |
190 /// Erase a key from the map. It called by the observer registry |
188 /// Erase a key from the map. It called by the observer registry |
191 /// and it overrides the erase() member function of the observer base. |
189 /// and it overrides the erase() member function of the observer base. |
192 void erase(const KeyType&) {} |
190 void erase(const Key&) {} |
193 |
191 |
194 /// Buildes the map. |
192 /// Buildes the map. |
195 |
193 |
196 /// It buildes the map. It called by the observer registry |
194 /// It buildes the map. It called by the observer registry |
197 /// and it overrides the build() member function of the observer base. |
195 /// and it overrides the build() member function of the observer base. |