132 /// the NodeMap. In this case the value for each item |
132 /// the NodeMap. In this case the value for each item |
133 /// is assigned by the value of the given ReadMap. |
133 /// is assigned by the value of the given ReadMap. |
134 template <typename CMap> |
134 template <typename CMap> |
135 VectorMap& operator=(const CMap& cmap) { |
135 VectorMap& operator=(const CMap& cmap) { |
136 checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); |
136 checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); |
137 const typename Parent::Notifier* notifier = Parent::notifier(); |
137 const typename Parent::Notifier* nf = Parent::notifier(); |
138 Item it; |
138 Item it; |
139 for (notifier->first(it); it != INVALID; notifier->next(it)) { |
139 for (nf->first(it); it != INVALID; nf->next(it)) { |
140 set(it, cmap[it]); |
140 set(it, cmap[it]); |
141 } |
141 } |
142 return *this; |
142 return *this; |
143 } |
143 } |
144 |
144 |
174 /// |
174 /// |
175 /// It adds a new key to the map. It called by the observer notifier |
175 /// It adds a new key to the map. It called by the observer notifier |
176 /// and it overrides the add() member function of the observer base. |
176 /// and it overrides the add() member function of the observer base. |
177 virtual void add(const Key& key) { |
177 virtual void add(const Key& key) { |
178 int id = Parent::notifier()->id(key); |
178 int id = Parent::notifier()->id(key); |
179 if (id >= (int)container.size()) { |
179 if (id >= int(container.size())) { |
180 container.resize(id + 1); |
180 container.resize(id + 1); |
181 } |
181 } |
182 } |
182 } |
183 |
183 |
184 /// \brief Adds more new keys to the map. |
184 /// \brief Adds more new keys to the map. |
185 /// |
185 /// |
186 /// It adds more new keys to the map. It called by the observer notifier |
186 /// It adds more new keys to the map. It called by the observer notifier |
187 /// and it overrides the add() member function of the observer base. |
187 /// and it overrides the add() member function of the observer base. |
188 virtual void add(const std::vector<Key>& keys) { |
188 virtual void add(const std::vector<Key>& keys) { |
189 int max = container.size() - 1; |
189 int max = container.size() - 1; |
190 for (int i = 0; i < (int)keys.size(); ++i) { |
190 for (int i = 0; i < int(keys.size()); ++i) { |
191 int id = Parent::notifier()->id(keys[i]); |
191 int id = Parent::notifier()->id(keys[i]); |
192 if (id >= max) { |
192 if (id >= max) { |
193 max = id; |
193 max = id; |
194 } |
194 } |
195 } |
195 } |
207 /// \brief Erase more keys from the map. |
207 /// \brief Erase more keys from the map. |
208 /// |
208 /// |
209 /// Erase more keys from the map. It called by the observer notifier |
209 /// Erase more keys from the map. It called by the observer notifier |
210 /// and it overrides the erase() member function of the observer base. |
210 /// and it overrides the erase() member function of the observer base. |
211 virtual void erase(const std::vector<Key>& keys) { |
211 virtual void erase(const std::vector<Key>& keys) { |
212 for (int i = 0; i < (int)keys.size(); ++i) { |
212 for (int i = 0; i < int(keys.size()); ++i) { |
213 container[Parent::notifier()->id(keys[i])] = Value(); |
213 container[Parent::notifier()->id(keys[i])] = Value(); |
214 } |
214 } |
215 } |
215 } |
216 |
216 |
217 /// \brief Buildes the map. |
217 /// \brief Buildes the map. |