equal
deleted
inserted
replaced
95 Reference(IterableBoolMap& map, const Key& key) |
95 Reference(IterableBoolMap& map, const Key& key) |
96 : _key(key), _map(map) {} |
96 : _key(key), _map(map) {} |
97 public: |
97 public: |
98 |
98 |
99 Reference& operator=(const Reference& value) { |
99 Reference& operator=(const Reference& value) { |
100 _map.set(_key, (bool)value); |
100 _map.set(_key, static_cast<bool>(value)); |
101 return *this; |
101 return *this; |
102 } |
102 } |
103 |
103 |
104 operator bool() const { |
104 operator bool() const { |
105 return static_cast<const IterableBoolMap&>(_map)[_key]; |
105 return static_cast<const IterableBoolMap&>(_map)[_key]; |
245 /// |
245 /// |
246 /// Creates an iterator. It iterates on the |
246 /// Creates an iterator. It iterates on the |
247 /// keys which mapped to false. |
247 /// keys which mapped to false. |
248 /// \param _map The IterableIntMap |
248 /// \param _map The IterableIntMap |
249 explicit FalseIt(const IterableBoolMap& _map) |
249 explicit FalseIt(const IterableBoolMap& _map) |
250 : Parent(_map.sep < (int)_map.array.size() ? |
250 : Parent(_map.sep < int(_map.array.size()) ? |
251 _map.array.back() : INVALID), map(&_map) {} |
251 _map.array.back() : INVALID), map(&_map) {} |
252 |
252 |
253 /// \brief Invalid constructor \& conversion. |
253 /// \brief Invalid constructor \& conversion. |
254 /// |
254 /// |
255 /// This constructor initializes the key to be invalid. |
255 /// This constructor initializes the key to be invalid. |
286 /// keys which mapped to false. |
286 /// keys which mapped to false. |
287 /// \param _map The IterableIntMap |
287 /// \param _map The IterableIntMap |
288 /// \param value Which elements should be iterated. |
288 /// \param value Which elements should be iterated. |
289 ItemIt(const IterableBoolMap& _map, bool value) |
289 ItemIt(const IterableBoolMap& _map, bool value) |
290 : Parent(value ? (_map.sep > 0 ? _map.array[_map.sep - 1] : INVALID) : |
290 : Parent(value ? (_map.sep > 0 ? _map.array[_map.sep - 1] : INVALID) : |
291 (_map.sep < (int)_map.array.size() ? |
291 (_map.sep < int(_map.array.size()) ? |
292 _map.array.back() : INVALID)), map(&_map) {} |
292 _map.array.back() : INVALID)), map(&_map) {} |
293 |
293 |
294 /// \brief Invalid constructor \& conversion. |
294 /// \brief Invalid constructor \& conversion. |
295 /// |
295 /// |
296 /// This constructor initializes the key to be invalid. |
296 /// This constructor initializes the key to be invalid. |
319 array.push_back(key); |
319 array.push_back(key); |
320 } |
320 } |
321 |
321 |
322 virtual void add(const std::vector<Key>& keys) { |
322 virtual void add(const std::vector<Key>& keys) { |
323 Parent::add(keys); |
323 Parent::add(keys); |
324 for (int i = 0; i < (int)keys.size(); ++i) { |
324 for (int i = 0; i < int(keys.size()); ++i) { |
325 Parent::set(keys[i], array.size()); |
325 Parent::set(keys[i], array.size()); |
326 array.push_back(keys[i]); |
326 array.push_back(keys[i]); |
327 } |
327 } |
328 } |
328 } |
329 |
329 |
343 } |
343 } |
344 Parent::erase(key); |
344 Parent::erase(key); |
345 } |
345 } |
346 |
346 |
347 virtual void erase(const std::vector<Key>& keys) { |
347 virtual void erase(const std::vector<Key>& keys) { |
348 for (int i = 0; i < (int)keys.size(); ++i) { |
348 for (int i = 0; i < int(keys.size()); ++i) { |
349 int pos = position(keys[i]); |
349 int pos = position(keys[i]); |
350 if (pos < sep) { |
350 if (pos < sep) { |
351 --sep; |
351 --sep; |
352 Parent::set(array[sep], pos); |
352 Parent::set(array[sep], pos); |
353 array[pos] = array[sep]; |
353 array[pos] = array[sep]; |
454 } |
454 } |
455 |
455 |
456 void lace(const Key& key) { |
456 void lace(const Key& key) { |
457 typename Parent::Value& node = Parent::operator[](key); |
457 typename Parent::Value& node = Parent::operator[](key); |
458 if (node.value < 0) return; |
458 if (node.value < 0) return; |
459 if (node.value >= (int)first.size()) { |
459 if (node.value >= int(first.size())) { |
460 first.resize(node.value + 1, INVALID); |
460 first.resize(node.value + 1, INVALID); |
461 } |
461 } |
462 node.prev = INVALID; |
462 node.prev = INVALID; |
463 node.next = first[node.value]; |
463 node.next = first[node.value]; |
464 if (node.next != INVALID) { |
464 if (node.next != INVALID) { |
482 Reference(IterableIntMap& map, const Key& key) |
482 Reference(IterableIntMap& map, const Key& key) |
483 : _key(key), _map(map) {} |
483 : _key(key), _map(map) {} |
484 public: |
484 public: |
485 |
485 |
486 Reference& operator=(const Reference& value) { |
486 Reference& operator=(const Reference& value) { |
487 _map.set(_key, (const int&)value); |
487 _map.set(_key, static_cast<const int&>(value)); |
488 return *this; |
488 return *this; |
489 } |
489 } |
490 |
490 |
491 operator const int&() const { |
491 operator const int&() const { |
492 return static_cast<const IterableIntMap&>(_map)[_key]; |
492 return static_cast<const IterableIntMap&>(_map)[_key]; |
615 /// Creates an iterator with a value. It iterates on the |
615 /// Creates an iterator with a value. It iterates on the |
616 /// keys which have the given value. |
616 /// keys which have the given value. |
617 /// \param map The IterableIntMap |
617 /// \param map The IterableIntMap |
618 /// \param value The value |
618 /// \param value The value |
619 ItemIt(const IterableIntMap& map, int value) : _map(&map) { |
619 ItemIt(const IterableIntMap& map, int value) : _map(&map) { |
620 if (value < 0 || value >= (int)_map->first.size()) { |
620 if (value < 0 || value >= int(_map->first.size())) { |
621 Parent::operator=(INVALID); |
621 Parent::operator=(INVALID); |
622 } else { |
622 } else { |
623 Parent::operator=(_map->first[value]); |
623 Parent::operator=(_map->first[value]); |
624 } |
624 } |
625 } |
625 } |
644 unlace(key); |
644 unlace(key); |
645 Parent::erase(key); |
645 Parent::erase(key); |
646 } |
646 } |
647 |
647 |
648 virtual void erase(const std::vector<Key>& keys) { |
648 virtual void erase(const std::vector<Key>& keys) { |
649 for (int i = 0; i < (int)keys.size(); ++i) { |
649 for (int i = 0; i < int(keys.size()); ++i) { |
650 unlace(keys[i]); |
650 unlace(keys[i]); |
651 } |
651 } |
652 Parent::erase(keys); |
652 Parent::erase(keys); |
653 } |
653 } |
654 |
654 |
882 unlace(key); |
882 unlace(key); |
883 } |
883 } |
884 |
884 |
885 virtual void add(const std::vector<Key>& keys) { |
885 virtual void add(const std::vector<Key>& keys) { |
886 Parent::add(keys); |
886 Parent::add(keys); |
887 for (int i = 0; i < (int)keys.size(); ++i) { |
887 for (int i = 0; i < int(keys.size()); ++i) { |
888 lace(keys[i]); |
888 lace(keys[i]); |
889 } |
889 } |
890 } |
890 } |
891 |
891 |
892 virtual void erase(const Key& key) { |
892 virtual void erase(const Key& key) { |
893 unlace(key); |
893 unlace(key); |
894 Parent::erase(key); |
894 Parent::erase(key); |
895 } |
895 } |
896 |
896 |
897 virtual void erase(const std::vector<Key>& keys) { |
897 virtual void erase(const std::vector<Key>& keys) { |
898 for (int i = 0; i < (int)keys.size(); ++i) { |
898 for (int i = 0; i < int(keys.size()); ++i) { |
899 unlace(keys[i]); |
899 unlace(keys[i]); |
900 } |
900 } |
901 Parent::erase(keys); |
901 Parent::erase(keys); |
902 } |
902 } |
903 |
903 |