163 for (notifier->first(it); it != INVALID; notifier->next(it)) { |
163 for (notifier->first(it); it != INVALID; notifier->next(it)) { |
164 LEMON_ASSERT(flag[Parent::notifier()->id(it)], MapError()); |
164 LEMON_ASSERT(flag[Parent::notifier()->id(it)], MapError()); |
165 flag[Parent::notifier()->id(it)] = false; |
165 flag[Parent::notifier()->id(it)] = false; |
166 } |
166 } |
167 } |
167 } |
168 for (int i = 0; i < (int)flag.size(); ++i) { |
168 for (int i = 0; i < int(flag.size()); ++i) { |
169 LEMON_ASSERT(!flag[i], MapError()); |
169 LEMON_ASSERT(!flag[i], MapError()); |
170 } |
170 } |
171 } |
171 } |
172 |
172 |
173 /// \brief Assign operator. |
173 /// \brief Assign operator. |
233 /// |
233 /// |
234 /// It adds a new key to the map. It called by the observer notifier |
234 /// It adds a new key to the map. It called by the observer notifier |
235 /// and it overrides the add() member function of the observer base. |
235 /// and it overrides the add() member function of the observer base. |
236 virtual void add(const Key& key) { |
236 virtual void add(const Key& key) { |
237 int id = Parent::notifier()->id(key); |
237 int id = Parent::notifier()->id(key); |
238 if (id >= (int)container.size()) { |
238 if (id >= int(container.size())) { |
239 container.resize(id + 1); |
239 container.resize(id + 1); |
240 flag.resize(id + 1, false); |
240 flag.resize(id + 1, false); |
241 } |
241 } |
242 LEMON_ASSERT(!flag[Parent::notifier()->id(key)], MapError()); |
242 LEMON_ASSERT(!flag[Parent::notifier()->id(key)], MapError()); |
243 flag[Parent::notifier()->id(key)] = true; |
243 flag[Parent::notifier()->id(key)] = true; |
244 if (strictCheck) { |
244 if (strictCheck) { |
245 std::vector<bool> fl(flag.size(), false); |
245 std::vector<bool> fl(flag.size(), false); |
246 const typename Parent::Notifier* notifier = Parent::notifier(); |
246 const typename Parent::Notifier* notifier = Parent::notifier(); |
247 Item it; |
247 Item it; |
248 for (notifier->first(it); it != INVALID; notifier->next(it)) { |
248 for (notifier->first(it); it != INVALID; notifier->next(it)) { |
249 int id = Parent::notifier()->id(it); |
249 int jd = Parent::notifier()->id(it); |
250 fl[id] = true; |
250 fl[jd] = true; |
251 } |
251 } |
252 LEMON_ASSERT(fl == flag, MapError()); |
252 LEMON_ASSERT(fl == flag, MapError()); |
253 } |
253 } |
254 } |
254 } |
255 |
255 |
257 /// |
257 /// |
258 /// It adds more new keys to the map. It called by the observer notifier |
258 /// It adds more new keys to the map. It called by the observer notifier |
259 /// and it overrides the add() member function of the observer base. |
259 /// and it overrides the add() member function of the observer base. |
260 virtual void add(const std::vector<Key>& keys) { |
260 virtual void add(const std::vector<Key>& keys) { |
261 int max = container.size() - 1; |
261 int max = container.size() - 1; |
262 for (int i = 0; i < (int)keys.size(); ++i) { |
262 for (int i = 0; i < int(keys.size()); ++i) { |
263 int id = Parent::notifier()->id(keys[i]); |
263 int id = Parent::notifier()->id(keys[i]); |
264 if (id >= max) { |
264 if (id >= max) { |
265 max = id; |
265 max = id; |
266 } |
266 } |
267 } |
267 } |
268 container.resize(max + 1); |
268 container.resize(max + 1); |
269 flag.resize(max + 1, false); |
269 flag.resize(max + 1, false); |
270 for (int i = 0; i < (int)keys.size(); ++i) { |
270 for (int i = 0; i < int(keys.size()); ++i) { |
271 LEMON_ASSERT(!flag[Parent::notifier()->id(keys[i])], MapError()); |
271 LEMON_ASSERT(!flag[Parent::notifier()->id(keys[i])], MapError()); |
272 flag[Parent::notifier()->id(keys[i])] = true; |
272 flag[Parent::notifier()->id(keys[i])] = true; |
273 } |
273 } |
274 if (strictCheck) { |
274 if (strictCheck) { |
275 std::vector<bool> fl(flag.size(), false); |
275 std::vector<bool> fl(flag.size(), false); |
316 int id = Parent::notifier()->id(it); |
316 int id = Parent::notifier()->id(it); |
317 fl[id] = true; |
317 fl[id] = true; |
318 } |
318 } |
319 LEMON_ASSERT(fl == flag, MapError()); |
319 LEMON_ASSERT(fl == flag, MapError()); |
320 } |
320 } |
321 for (int i = 0; i < (int)keys.size(); ++i) { |
321 for (int i = 0; i < int(keys.size()); ++i) { |
322 container[Parent::notifier()->id(keys[i])] = Value(); |
322 container[Parent::notifier()->id(keys[i])] = Value(); |
323 LEMON_ASSERT(flag[Parent::notifier()->id(keys[i])], MapError()); |
323 LEMON_ASSERT(flag[Parent::notifier()->id(keys[i])], MapError()); |
324 flag[Parent::notifier()->id(keys[i])] = false; |
324 flag[Parent::notifier()->id(keys[i])] = false; |
325 } |
325 } |
326 } |
326 } |
329 /// |
329 /// |
330 /// It buildes the map. It called by the observer notifier |
330 /// It buildes the map. It called by the observer notifier |
331 /// and it overrides the build() member function of the observer base. |
331 /// and it overrides the build() member function of the observer base. |
332 virtual void build() { |
332 virtual void build() { |
333 if (strictCheck) { |
333 if (strictCheck) { |
334 for (int i = 0; i < (int)flag.size(); ++i) { |
334 for (int i = 0; i < int(flag.size()); ++i) { |
335 LEMON_ASSERT(flag[i], MapError()); |
335 LEMON_ASSERT(flag[i], MapError()); |
336 } |
336 } |
337 } |
337 } |
338 int size = Parent::notifier()->maxId() + 1; |
338 int size = Parent::notifier()->maxId() + 1; |
339 container.reserve(size); |
339 container.reserve(size); |
360 int id = Parent::notifier()->id(it); |
360 int id = Parent::notifier()->id(it); |
361 LEMON_ASSERT(flag[id], MapError()); |
361 LEMON_ASSERT(flag[id], MapError()); |
362 flag[id] = false; |
362 flag[id] = false; |
363 } |
363 } |
364 if (strictCheck) { |
364 if (strictCheck) { |
365 for (int i = 0; i < (int)flag.size(); ++i) { |
365 for (int i = 0; i < int(flag.size()); ++i) { |
366 LEMON_ASSERT(!flag[i], MapError()); |
366 LEMON_ASSERT(!flag[i], MapError()); |
367 } |
367 } |
368 } |
368 } |
369 container.clear(); |
369 container.clear(); |
370 flag.clear(); |
370 flag.clear(); |