53 typename T,
typename Compare = std::less<T>,
54 typename Container = std::vector<T>>
104 template<
typename Key,
typename T,
typename Compare = std::less<Key>>
129 template<
typename... Params>
130 void emplace(
const Key& key, Params&&... params);
142 return Compare()(lhs.
key, rhs.
key);
145 return Compare()(lhs.
key, rhs_key);
148 return Compare()(lhs_key, rhs.
key);
158 template<
typename T,
typename Compare,
typename Container>
162 auto pos = find(std::forward<U>(
u));
164 throw std::out_of_range(
"The requested element does not exists");
169 template<
typename T,
typename Compare,
typename Container>
172 auto pos = std::lower_bound(m_items.begin(), m_items.end(),
t, Compare());
173 if (((
pos != m_items.end()) and !Compare()(
t, *
pos))) {
176 m_items.emplace(
pos, t);
180 template<
typename T,
typename Compare,
typename Container>
184 auto end = m_items.end();
186 std::lower_bound(m_items.begin(), end, std::forward<U>(
u), Compare());
187 return ((
pos != end) and !Compare()(std::forward<U>(
u), *
pos)) ?
pos : end;
190 template<
typename T,
typename Compare,
typename Container>
194 return std::binary_search(
195 m_items.begin(), m_items.end(), std::forward<U>(
u), Compare());
200 template<
typename Key,
typename T,
typename Compare>
201 template<
typename... Params>
204 auto idx = m_keys.find(key);
205 if (
idx != m_keys.end()) {
206 m_items[
idx->index] =
T(std::forward<Params>(params)...);
208 m_items.emplace_back(std::forward<Params>(params)...);
209 m_keys.insert_or_assign(
KeyIndex{key, m_items.size() - 1});