5 template<
typename T,
typename K>
6 Map<T,K>::Map(Allocator* allocator) noexcept:
12 template<
typename T,
typename K>
13 Map<T, K>::~Map() noexcept
18 template<
typename T,
typename K>
19 Map<T, K>::Map(
const Map& rhs) noexcept :
25 template<
typename T,
typename K>
26 Map<T, K>& Map<T, K>::operator=(
const Map& rhs) noexcept
32 template<
typename T,
typename K>
33 Map<T, K>::Map(Map&& rhs) noexcept :
34 m_data(std::move(rhs.m_data))
38 template<
typename T,
typename K>
39 Map<T, K>& Map<T, K>::operator=(Map&& rhs) noexcept
41 m_data = std::move(rhs.m_data);
45 template<
typename T,
typename K>
46 bool Map<T, K>::operator==(
const Map& rhs)
const noexcept
48 if (rhs.m_data.length() != m_data.length())
return false;
49 for (
size_t i = 0; i < m_data.length(); ++i)
51 auto& item = m_data[i];
52 auto& rhs_item = rhs.m_data[i];
53 if (item.first != rhs_item.first || item.second != rhs_item.second)
return false;
58 template<
typename T,
typename K>
59 void Map<T, K>::clear() noexcept
64 template<
typename T,
typename K>
65 size_t Map<T, K>::size() const noexcept
67 return m_data.length();
70 template<
typename T,
typename K>
71 size_t Map<T, K>::length() const noexcept
73 return m_data.length();
76 template<
typename T,
typename K>
77 size_t Map<T, K>::capacity() const noexcept
79 return m_data.capacity();
82 template<
typename T,
typename K>
83 void Map<T, K>::reserve(
size_t new_capacity) noexcept
85 return m_data.reserve(new_capacity);
88 template<
typename T,
typename K>
89 typename Map<T, K >::iterator Map<T, K>::find(
const T& key) noexcept
92 for (
auto it = begin(); it != end_it; ++it)
94 if (it->first == key)
return it;
99 template<
typename T,
typename K>
100 typename Map<T, K >::const_iterator Map<T, K>::find(
const T& key)
const noexcept
102 auto end_it = cend();
103 for (
auto it = cbegin(); it != end_it; ++it)
105 if (it->first == key)
return it;
110 template<
typename T,
typename K>
111 constexpr K& Map<T, K>::operator[](
const T& key) noexcept
117 m_data.emplace_back(key, K());
118 return m_data.back().second;
121 template<
typename T,
typename K>
122 constexpr K& Map<T, K>::operator[](T&& key) noexcept
128 m_data.emplace_back(key, K());
129 return m_data.back().second;
132 template<
typename T,
typename K>
133 typename Map<T, K>::iterator Map<T, K>::emplace(T&& key, K&& value) noexcept
138 m_data.emplace_back(key, value);
139 return m_data.begin() + (m_data.length() - 1);
142 template<
typename T,
typename K>
143 typename Map<T, K>::iterator Map<T, K>::emplace(
const T& key,
const K& value) noexcept
148 m_data.emplace_back(key, value);
149 return m_data.begin() + (m_data.length() - 1);
152 template<
typename T,
typename K>
155 return m_data.begin();
158 template<
typename T,
typename K>
164 template<
typename T,
typename K>
165 typename Map<T, K>::const_iterator Map<T, K>::cbegin() const noexcept
167 return m_data.cbegin();
170 template<
typename T,
typename K>
171 typename Map<T, K>::const_iterator Map<T, K>::cend() const noexcept
173 return m_data.cend();
176 template<
typename T,
typename K>
177 typename Map<T, K>::reverse_iterator Map<T, K>::rbegin() noexcept
179 return reverse_iterator(&m_data.back());
182 template<
typename T,
typename K>
183 typename Map<T, K>::reverse_iterator Map<T, K>::rend() noexcept
185 Entry* front_ptr = &m_data.front();
186 return reverse_iterator(--front_ptr);
189 template<
typename T,
typename K>
190 typename Map<T, K>::const_reverse_iterator Map<T, K>::crbegin() const noexcept
192 return const_reverse_iterator(&m_data.back());
195 template<
typename T,
typename K>
196 typename Map<T, K>::const_reverse_iterator Map<T, K>::crend() const noexcept
198 Entry* front_ptr =
const_cast<Entry*
>(&m_data.front());
199 return const_reverse_iterator(--front_ptr);
202 template<
typename T,
typename K>
203 typename Map<T, K>::iterator Map<T, K>::erase(iterator it) noexcept
205 if (it == end())
return it;
206 auto index = it - begin();
208 return begin() + index;
211 template<
typename T,
typename K>
212 void Map<T, K>::erase(
const T& key) noexcept