31#ifndef ETL_CONST_MULTIMAP_INCLUDED
32#define ETL_CONST_MULTIMAP_INCLUDED
36#if ETL_NOT_USING_CPP11
37 #error NOT SUPPORTED FOR C++03 OR BELOW
53 template <
typename TKey,
typename TMapped,
typename TKeyCompare = etl::less<TKey>>
58 using key_type = TKey;
59 using value_type = ETL_OR_STD::pair<const TKey, TMapped>;
60 using mapped_type = TMapped ;
61 using key_compare = TKeyCompare;
62 using const_reference =
const value_type&;
63 using const_pointer =
const value_type*;
64 using const_iterator =
const value_type*;
65 using size_type = size_t;
75 ETL_CONSTEXPR14
bool operator ()(
const value_type& element1,
const value_type& element2)
const ETL_NOEXCEPT
77 return kcompare(element1.first, element2.first);
81 ETL_CONSTEXPR14
bool operator ()(
const value_type& element,
const key_type& key)
const ETL_NOEXCEPT
83 return kcompare(element.first, key);
88 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
89 ETL_CONSTEXPR14
bool operator ()(
const value_type& element,
const K& key)
const ETL_NOEXCEPT
91 return kcompare(element.first, key);
95 ETL_CONSTEXPR14
bool operator ()(
const key_type& key,
const value_type& element)
const ETL_NOEXCEPT
97 return kcompare(key, element.first);
102 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
103 ETL_CONSTEXPR14
bool operator ()(
const K& key,
const value_type& element)
const ETL_NOEXCEPT
105 return kcompare(key, element.first);
108 key_compare kcompare;
125 ETL_CONSTEXPR14 const_iterator
begin() const ETL_NOEXCEPT
134 ETL_CONSTEXPR14 const_iterator
cbegin() const ETL_NOEXCEPT
143 ETL_CONSTEXPR14 const_iterator
end() const ETL_NOEXCEPT
145 return element_list_end;
152 ETL_CONSTEXPR14 const_iterator
cend() const ETL_NOEXCEPT
154 return element_list_end;
161 ETL_CONSTEXPR14 const_pointer
data() const ETL_NOEXCEPT
172 ETL_CONSTEXPR14 const_iterator
find(
const key_type& key)
const ETL_NOEXCEPT
176 if ((itr !=
end()) && (keys_are_equal(itr->first, key)))
191 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
192 ETL_CONSTEXPR14 const_iterator
find(
const K& key)
const ETL_NOEXCEPT
196 if ((itr !=
end()) && (keys_are_equal(itr->first, key)))
209 ETL_CONSTEXPR14
bool contains(
const key_type& key)
const ETL_NOEXCEPT
220 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
221 ETL_CONSTEXPR14
bool contains(
const K& key)
const ETL_NOEXCEPT
231 ETL_CONSTEXPR14 size_type
count(
const key_type& key)
const ETL_NOEXCEPT
235 return size_type(etl::distance(range.first, range.second));
244 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
245 ETL_CONSTEXPR14 size_type
count(
const K& key)
const ETL_NOEXCEPT
249 return size_type(etl::distance(range.first, range.second));
260 ETL_CONSTEXPR14 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const key_type& key)
const ETL_NOEXCEPT
262 return etl::equal_range(
begin(),
end(), key, vcompare);
274 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
275 ETL_CONSTEXPR14 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const ETL_NOEXCEPT
277 return etl::equal_range(
begin(),
end(), key, vcompare);
286 ETL_CONSTEXPR14 const_iterator
lower_bound(
const key_type& key)
const ETL_NOEXCEPT
288 return etl::lower_bound(
begin(),
end(), key, vcompare);
298 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
299 ETL_CONSTEXPR14 const_iterator
lower_bound(
const K& key)
const ETL_NOEXCEPT
301 return etl::lower_bound(
begin(),
end(), key, vcompare);
310 ETL_CONSTEXPR14 const_iterator
upper_bound(
const key_type& key)
const ETL_NOEXCEPT
312 return etl::upper_bound(
begin(),
end(), key, vcompare);
322 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
323 ETL_CONSTEXPR14 const_iterator
upper_bound(
const K& key)
const ETL_NOEXCEPT
325 return etl::upper_bound(
begin(),
end(), key, vcompare);
332 ETL_CONSTEXPR14 size_type
empty() const ETL_NOEXCEPT
341 ETL_CONSTEXPR14 size_type
full() const ETL_NOEXCEPT
343 return (max_elements != 0) && (
size() == max_elements);
350 ETL_CONSTEXPR14 size_type
size() const ETL_NOEXCEPT
352 return size_type(element_list_end - element_list);
359 ETL_CONSTEXPR14 size_type
max_size() const ETL_NOEXCEPT
369 ETL_CONSTEXPR14 size_type
capacity() const ETL_NOEXCEPT
378 ETL_CONSTEXPR14 key_compare
key_comp() const ETL_NOEXCEPT
380 return vcompare.kcompare;
387 ETL_CONSTEXPR14 value_compare
value_comp() const ETL_NOEXCEPT
397 template <
typename... TElements>
398 ETL_CONSTEXPR14
explicit iconst_multimap(
const value_type* element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT
399 : element_list(element_list_)
400 , element_list_end{element_list_ + size_}
401 , max_elements(max_elements_)
410 ETL_CONSTEXPR14
bool keys_are_equal(
const key_type& key1,
const key_type& key2)
const ETL_NOEXCEPT
412 return !key_compare()(key1, key2) && !key_compare()(key2, key1);
419 template <typename K1, typename K2, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
420 ETL_CONSTEXPR14
bool keys_are_equal(
const K1& key1,
const K2& key2)
const ETL_NOEXCEPT
422 return !key_compare()(key1, key2) && !key_compare()(key2, key1);
427 const value_type* element_list;
428 const value_type* element_list_end;
429 size_type max_elements;
435 template <
typename TKey,
typename TMapped,
size_t Size,
typename TKeyCompare = etl::less<TKey>>
442 using key_type =
typename base_t::key_type;
443 using value_type =
typename base_t::value_type;
444 using mapped_type =
typename base_t::mapped_type;
445 using key_compare =
typename base_t::key_compare;
446 using const_reference =
typename base_t::const_reference;
447 using const_pointer =
typename base_t::const_pointer;
448 using const_iterator =
typename base_t::const_iterator;
449 using size_type =
typename base_t::size_type;
451 static_assert((etl::is_default_constructible<key_type>::value),
"key_type must be default constructible");
452 static_assert((etl::is_default_constructible<mapped_type>::value),
"mapped_type must be default constructible");
460 template <
typename... TElements>
463 , element_list{etl::forward<TElements>(elements)...}
465 static_assert((etl::are_all_same<value_type, etl::decay_t<TElements>...>::value),
"All elements must be value_type");
466 static_assert(
sizeof...(elements) <= Size,
"Number of elements exceeds capacity");
471 value_type element_list[Size];
478 template <
typename... TPairs>
480 typename etl::nth_type_t<0, TPairs...>::second_type,
487 template <
typename TKey,
typename TMapped,
typename TKeyCompare = etl::less<TKey>>
494 using key_type =
typename base_t::key_type;
495 using value_type =
typename base_t::value_type;
496 using mapped_type =
typename base_t::mapped_type ;
497 using key_compare =
typename base_t::key_compare;
498 using const_reference =
typename base_t::const_reference;
499 using const_pointer =
typename base_t::const_pointer;
500 using const_iterator =
typename base_t::const_iterator;
501 using size_type =
typename base_t::size_type;
503 static_assert((etl::is_default_constructible<key_type>::value),
"key_type must be default constructible");
504 static_assert((etl::is_default_constructible<mapped_type>::value),
"mapped_type must be default constructible");
517 template <
size_type Size>
526 template <
size_type Size>
537 template <
typename TElements,
size_t Size>
538 const_multimap_ext(
const etl::span<TElements, Size>&) -> const_multimap_ext<typename TElements::first_type, typename TElements::second_type>;
540 template <
typename TElements,
size_t Size>
541 const_multimap_ext(
const TElements(&)[Size]) -> const_multimap_ext<typename TElements::first_type, typename TElements::second_type>;
547 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
551 return etl::equal(lhs.begin(), lhs.end(), rhs.begin());
557 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
561 return !(lhs == rhs);
571 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
575 return etl::lexicographical_compare(lhs.begin(), lhs.end(),
576 rhs.begin(), rhs.end(),
587 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
601 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
615 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
ETL_CONSTEXPR14 const_multimap_ext(const etl::span< const value_type, Size > &sp) ETL_NOEXCEPT
Construct a const_map from a variadic list of elements.
Definition const_multimap.h:518
ETL_CONSTEXPR14 const_multimap_ext(const value_type(&begin_)[Size]) ETL_NOEXCEPT
Construct a const_map from an array.
Definition const_multimap.h:527
ETL_CONSTEXPR14 const_multimap_ext() ETL_NOEXCEPT
Default construct a const_map.
Definition const_multimap.h:509
Multimap type designed for constexpr.
Definition const_multimap.h:437
ETL_CONSTEXPR14 const_multimap(TElements &&... elements) ETL_NOEXCEPT
Construct a const_map from a variadic list of elements. Static asserts if the element type is not con...
Definition const_multimap.h:461
How to compare elements and keys.
Definition const_multimap.h:71
Definition const_multimap.h:55
ETL_CONSTEXPR14 const_iterator lower_bound(const K &key) const ETL_NOEXCEPT
Returns a const_iterator to the first element that is not less than the key. Returns a const_iterator...
Definition const_multimap.h:299
ETL_CONSTEXPR14 size_type count(const K &key) const ETL_NOEXCEPT
Counts the numbeer elements with key. Enabled if the comparator is transparent.
Definition const_multimap.h:245
ETL_CONSTEXPR14 value_compare value_comp() const ETL_NOEXCEPT
Definition const_multimap.h:387
ETL_CONSTEXPR14 const_iterator upper_bound(const K &key) const ETL_NOEXCEPT
Returns a const_iterator to the first element that is greater than the key. Returns a const_iterator ...
Definition const_multimap.h:323
ETL_CONSTEXPR14 const_iterator end() const ETL_NOEXCEPT
Gets the end of the map.
Definition const_multimap.h:143
ETL_CONSTEXPR14 const_iterator lower_bound(const key_type &key) const ETL_NOEXCEPT
Returns a const_iterator to the first element that is not less than the key. Returns a const_iterator...
Definition const_multimap.h:286
ETL_CONSTEXPR14 key_compare key_comp() const ETL_NOEXCEPT
Definition const_multimap.h:378
ETL_CONSTEXPR14 const_iterator find(const K &key) const ETL_NOEXCEPT
Gets a const_iterator to the mapped value at the key index. Enabled if the comparator is transparent.
Definition const_multimap.h:192
ETL_CONSTEXPR14 bool contains(const K &key) const ETL_NOEXCEPT
Checks if the map contains an element with key. Enabled if the comparator is transparent.
Definition const_multimap.h:221
ETL_CONSTEXPR14 size_type empty() const ETL_NOEXCEPT
Definition const_multimap.h:332
ETL_CONSTEXPR14 ETL_OR_STD::pair< const_iterator, const_iterator > equal_range(const K &key) const ETL_NOEXCEPT
Returns a range containing all elements with the key. The range is defined by a pair of two iterators...
Definition const_multimap.h:275
ETL_CONSTEXPR14 size_type size() const ETL_NOEXCEPT
Definition const_multimap.h:350
ETL_CONSTEXPR14 size_type max_size() const ETL_NOEXCEPT
Definition const_multimap.h:359
ETL_CONSTEXPR14 iconst_multimap(const value_type *element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT
Constructor.
Definition const_multimap.h:398
ETL_CONSTEXPR14 const_iterator cbegin() const ETL_NOEXCEPT
Gets the beginning of the map.
Definition const_multimap.h:134
ETL_CONSTEXPR14 bool is_valid() const ETL_NOEXCEPT
Definition const_multimap.h:116
ETL_CONSTEXPR14 const_iterator find(const key_type &key) const ETL_NOEXCEPT
Gets a const_iterator to the mapped value at the key index.
Definition const_multimap.h:172
ETL_CONSTEXPR14 ETL_OR_STD::pair< const_iterator, const_iterator > equal_range(const key_type &key) const ETL_NOEXCEPT
Returns a range containing all elements with the key. The range is defined by a pair of two iterators...
Definition const_multimap.h:260
ETL_CONSTEXPR14 const_iterator upper_bound(const key_type &key) const ETL_NOEXCEPT
Returns a const_iterator to the first element that is greater than the key. Returns a const_iterator ...
Definition const_multimap.h:310
ETL_CONSTEXPR14 const_iterator begin() const ETL_NOEXCEPT
Gets the beginning of the map.
Definition const_multimap.h:125
ETL_CONSTEXPR14 const_iterator cend() const ETL_NOEXCEPT
Gets the end of the map.
Definition const_multimap.h:152
ETL_CONSTEXPR14 size_type full() const ETL_NOEXCEPT
Definition const_multimap.h:341
ETL_CONSTEXPR14 const_pointer data() const ETL_NOEXCEPT
Gets the beginning of the map.
Definition const_multimap.h:161
ETL_CONSTEXPR14 size_type capacity() const ETL_NOEXCEPT
Definition const_multimap.h:369
ETL_CONSTEXPR14 bool contains(const key_type &key) const ETL_NOEXCEPT
Checks if the map contains an element with key.
Definition const_multimap.h:209
ETL_CONSTEXPR14 size_type count(const key_type &key) const ETL_NOEXCEPT
Counts the numbeer elements with key.
Definition const_multimap.h:231
Span - Fixed Extent.
Definition span.h:138
ETL_NODISCARD ETL_CONSTEXPR14 bool is_sorted(TIterator begin, TIterator end)
Definition algorithm.h:1709
bitset_ext
Definition absolute.h:39
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1190
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1202
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1151
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1139
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1163
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1178