19template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
22template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
25 : comparator(comparator), value_comparator(comparator),
26 tree(value_comparator, allocator) {}
28template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
32template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
34 : comparator(
other.comparator), value_comparator(
other.comparator),
37template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
40 comparator =
other.comparator;
41 value_comparator =
other.comparator;
46template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
48 : comparator(std::move(
other.comparator)),
49 value_comparator(std::move(
other.comparator)),
50 tree(std::move(
other.tree)) {}
52template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
55 comparator = std::move(
other.comparator);
56 value_comparator = std::move(
other.comparator);
57 tree = std::move(
other.tree);
61template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
68template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
71 return tree.get_allocator();
74template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
80template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
83 return value_comparator;
88template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
92 if (node ==
nullptr) {
93 throw std::out_of_range(
"Key not found!");
95 return node->item.second;
98template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
102 if (node ==
nullptr) {
103 throw std::out_of_range(
"Key not found!");
105 return node->item.second;
108template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
115 return node->item.second;
118template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
127 return node->item.second;
130template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
137template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
144template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
148 return node !=
nullptr;
151template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
155 return node !=
nullptr ? 1 : 0;
158template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
165template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
173template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
180template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
188template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
189std::pair<typename map<TKey, TValue, TKeyComp, TAlloc>::iterator,
192 return std::make_pair(lower_bound(
key), upper_bound(
key));
195template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
196std::pair<typename map<TKey, TValue, TKeyComp, TAlloc>::const_iterator,
200 return std::make_pair(lower_bound(
key), upper_bound(
key));
205template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
208 return iterator(&tree, tree.min_from(tree.get_root()));
211template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
217template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
223template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
229template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
235template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
241template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
247template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
253template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
259template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
265template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
271template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
279template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
281 return tree.size() == 0;
284template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
290template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
292 return tree.get_height();
297template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
302template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
303std::pair<typename map<TKey, TValue, TKeyComp, TAlloc>::iterator,
bool>
312template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
313std::pair<typename map<TKey, TValue, TKeyComp, TAlloc>::iterator,
bool>
322template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
323template <
class TMapped>
324std::pair<typename map<TKey, TValue, TKeyComp, TAlloc>::iterator,
bool>
328 item.second = std::forward<TMapped>(
value);
339template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
340template <
class TMapped>
341std::pair<typename map<TKey, TValue, TKeyComp, TAlloc>::iterator,
bool>
345 item.second = std::forward<TMapped>(
value);
356template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
357template <
class... Args>
358std::pair<typename map<TKey, TValue, TKeyComp, TAlloc>::iterator,
bool>
362 return value_type(std::piecewise_construct, std::forward_as_tuple(
key),
363 std::forward_as_tuple(std::forward<Args>(
args)...));
371template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
372template <
class... Args>
373std::pair<typename map<TKey, TValue, TKeyComp, TAlloc>::iterator,
bool>
378 std::forward_as_tuple(std::move(
key)),
379 std::forward_as_tuple(std::forward<Args>(
args)...));
387template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
391 tree.erase(
tmp.node);
395template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
399 tree.erase(
tmp.node);
403template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
408 if (node ==
nullptr) {
417template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
419 std::swap(tree,
other.tree);
420 std::swap(comparator,
other.comparator);
421 std::swap(value_comparator,
other.value_comparator);
426template <
class TKey,
class TValue,
class TKeyComp,
class TAlloc>
The AVL tree iterator type.
Definition _avl_iterator.hpp:34
typename base::node_ptr node_ptr
Definition _avl.hpp:83
A map type using an AVL tree as the underlying structure.
Definition map.hpp:47
iterator erase(iterator pos) noexcept
Erases an item.
Definition map.ipp:389
iterator upper_bound(const key_type &key) noexcept
Returns an iterator to the first item which is greater that the given key.
Definition map.ipp:175
iterator find(const key_type &key) noexcept
Finds an item with the given key.
Definition map.ipp:132
int get_height() const noexcept
Returns the height of the underlying tree.
Definition map.ipp:291
reverse_iterator rbegin() noexcept
Returns a reverse iterator to the biggest item.
Definition map.ipp:243
iterator begin() noexcept
Returns an iterator to the smallest item.
Definition map.ipp:207
key_compare key_comp() const noexcept
Returns the function that compares keys.
Definition map.ipp:76
const_iterator cbegin() const noexcept
Returns explicitly a constant iterator to the smallest item.
Definition map.ipp:219
void clear() noexcept
Erases the whole tree.
Definition map.ipp:298
mapped_type & operator[](const key_type &key)
Access specified item or insert.
Definition map.ipp:110
mapped_type & at(const key_type &key)
Access specified item.
Definition map.ipp:90
~map() noexcept
Definition map.ipp:62
void swap(map &other) noexcept
Swaps the content.
Definition map.ipp:418
const_reverse_iterator crbegin() const noexcept
Returns explicitly a constant reverse iterator to the biggest item.
Definition map.ipp:255
map & operator=(const map &other)
Definition map.ipp:39
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition map.hpp:117
std::pair< iterator, bool > insert_or_assign(const key_type &key, TMapped &&value)
Inserts an item or assigns the value.
std::pair< const key_type, mapped_type > value_type
Definition map.hpp:53
iterator end() noexcept
Returns an iterator to the end.
Definition map.ipp:225
typename alloc_traits::size_type size_type
Definition map.hpp:99
std::pair< iterator, bool > try_emplace(const key_type &key, Args &&...args)
Construct an item in-place.
map()
Definition map.ipp:20
TKeyComp key_compare
Definition map.hpp:60
TAlloc allocator_type
Definition map.hpp:97
std::string to_dot(bool print_invis) const
Returns the dot representation of the tree.
Definition map.ipp:428
std::reverse_iterator< iterator > reverse_iterator
Definition map.hpp:116
allocator_type get_allocator() const noexcept
Returns the associated allocator.
Definition map.ipp:70
const_iterator cend() const noexcept
Returns explicitly a constant iterator to the end.
Definition map.ipp:237
value_compare value_comp() const noexcept
Returns the function that compares keys in the key, value pairs.
Definition map.ipp:82
TKey key_type
Definition map.hpp:51
size_type size() const noexcept
Returns the current number of items.
Definition map.ipp:286
std::pair< iterator, bool > insert(const value_type &item)
Inserts an item.
Definition map.ipp:304
const_reverse_iterator crend() const noexcept
Returns explicitly a constant reverse iterator to the end.
Definition map.ipp:273
bool contains(const key_type &key) const noexcept
Checks whether there exists an item with given key in the tree.
Definition map.ipp:145
TValue mapped_type
Definition map.hpp:52
bool empty() const noexcept
Checks whether the map contains any values.
Definition map.ipp:280
iterator lower_bound(const key_type &key) noexcept
Returns an iterator to the first item which is not less than the given key.
Definition map.ipp:160
size_type count(const key_type &key) const noexcept
Returns the number of items with the given key (0 or 1).
Definition map.ipp:153
std::pair< iterator, iterator > equal_range(const key_type &key) noexcept
Returns a range containing all the items with the given key.
Definition map.ipp:191
reverse_iterator rend() noexcept
Returns a reverse iterator to the end.
Definition map.ipp:261
Declarations of the ethereal map.
Declarations of the persistent map.
Definition _avl.hpp:14