31#ifndef ETL_CONST_MULTISET_INCLUDED
32#define ETL_CONST_MULTISET_INCLUDED
36#if ETL_NOT_USING_CPP11
37 #error NOT SUPPORTED FOR C++03 OR BELOW
53 template <
typename TKey,
typename TKeyCompare = etl::less<TKey>>
58 using key_type = TKey;
59 using value_type = TKey;
60 using key_compare = TKeyCompare;
61 using value_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;
72 ETL_CONSTEXPR14
bool is_valid() const ETL_NOEXCEPT
81 ETL_CONSTEXPR14 const_iterator
begin() const ETL_NOEXCEPT
90 ETL_CONSTEXPR14 const_iterator
cbegin() const ETL_NOEXCEPT
99 ETL_CONSTEXPR14 const_iterator
end() const ETL_NOEXCEPT
101 return element_list_end;
108 ETL_CONSTEXPR14 const_iterator
cend() const ETL_NOEXCEPT
110 return element_list_end;
117 ETL_CONSTEXPR14 const_pointer
data() const ETL_NOEXCEPT
128 ETL_CONSTEXPR14 const_iterator
find(
const key_type& key)
const ETL_NOEXCEPT
132 if ((itr !=
end()) && (keys_are_equal(*itr, key)))
147 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
148 ETL_CONSTEXPR14 const_iterator
find(
const K& key)
const ETL_NOEXCEPT
152 if ((itr !=
end()) && (keys_are_equal(*itr, key)))
165 ETL_CONSTEXPR14
bool contains(
const key_type& key)
const ETL_NOEXCEPT
176 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
177 ETL_CONSTEXPR14
bool contains(
const K& key)
const ETL_NOEXCEPT
187 ETL_CONSTEXPR14 size_type
count(
const key_type& key)
const ETL_NOEXCEPT
191 return size_type(etl::distance(range.first, range.second));
200 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
201 ETL_CONSTEXPR14 size_type
count(
const K& key)
const ETL_NOEXCEPT
205 return size_type(etl::distance(range.first, range.second));
216 ETL_CONSTEXPR14 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const key_type& key)
const ETL_NOEXCEPT
218 return etl::equal_range(
begin(),
end(), key, vcompare);
230 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
231 ETL_CONSTEXPR14 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const ETL_NOEXCEPT
233 return etl::equal_range(
begin(),
end(), key, vcompare);
244 ETL_CONSTEXPR14 const_iterator
lower_bound(
const key_type& key)
const ETL_NOEXCEPT
246 return etl::lower_bound(
begin(),
end(), key, vcompare);
257 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
258 ETL_CONSTEXPR14 const_iterator
lower_bound(
const K& key)
const ETL_NOEXCEPT
260 return etl::lower_bound(
begin(),
end(), key, vcompare);
271 ETL_CONSTEXPR14 const_iterator
upper_bound(
const key_type& key)
const ETL_NOEXCEPT
273 return etl::upper_bound(
begin(),
end(), key, vcompare);
284 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
285 ETL_CONSTEXPR14 const_iterator
upper_bound(
const K& key)
const ETL_NOEXCEPT
287 return etl::upper_bound(
begin(),
end(), key, vcompare);
294 ETL_CONSTEXPR14 size_type
empty() const ETL_NOEXCEPT
303 ETL_CONSTEXPR14 size_type
full() const ETL_NOEXCEPT
305 return (max_elements != 0) && (
size() == max_elements);
312 ETL_CONSTEXPR14 size_type
size() const ETL_NOEXCEPT
314 return size_type(element_list_end - element_list);
321 ETL_CONSTEXPR14 size_type
max_size() const ETL_NOEXCEPT
331 ETL_CONSTEXPR14 size_type
capacity() const ETL_NOEXCEPT
340 ETL_CONSTEXPR14 key_compare
key_comp() const ETL_NOEXCEPT
349 ETL_CONSTEXPR14 value_compare
value_comp() const ETL_NOEXCEPT
359 template <
typename... TElements>
360 ETL_CONSTEXPR14
explicit iconst_multiset(
const value_type* element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT
361 : element_list(element_list_)
362 , element_list_end{element_list_ + size_}
363 , max_elements(max_elements_)
372 ETL_CONSTEXPR14
bool keys_are_equal(
const key_type& key1,
const key_type& key2)
const ETL_NOEXCEPT
374 return !key_compare()(key1, key2) && !key_compare()(key2, key1);
381 template <typename K1, typename K2, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
382 ETL_CONSTEXPR14
bool keys_are_equal(
const K1& key1,
const K2& key2)
const ETL_NOEXCEPT
384 return !key_compare()(key1, key2) && !key_compare()(key2, key1);
387 key_compare kcompare;
388 value_compare vcompare;
390 const value_type* element_list;
391 const value_type* element_list_end;
392 size_type max_elements;
398 template <
typename TKey,
size_t Size,
typename TKeyCompare = etl::less<TKey>>
405 using key_type =
typename base_t::key_type;
406 using value_type =
typename base_t::value_type;
407 using key_compare =
typename base_t::key_compare;
408 using const_reference =
typename base_t::const_reference;
409 using const_pointer =
typename base_t::const_pointer;
410 using const_iterator =
typename base_t::const_iterator;
411 using size_type =
typename base_t::size_type;
413 static_assert((etl::is_default_constructible<key_type>::value),
"key_type must be default constructible");
422 template <
typename... TElements>
425 , element_list{etl::forward<TElements>(elements)...}
427 static_assert((etl::are_all_same<value_type, etl::decay_t<TElements>...>::value),
"All elements must be value_type");
428 static_assert(
sizeof...(elements) <= Size,
"Number of elements exceeds capacity");
433 value_type element_list[Size];
440 template <
typename... TElements>
447 template <
typename TKey,
typename TKeyCompare = etl::less<TKey>>
454 using key_type =
typename base_t::key_type;
455 using value_type =
typename base_t::value_type;
456 using key_compare =
typename base_t::key_compare;
457 using const_reference =
typename base_t::const_reference;
458 using const_pointer =
typename base_t::const_pointer;
459 using const_iterator =
typename base_t::const_iterator;
460 using size_type =
typename base_t::size_type;
462 static_assert((etl::is_default_constructible<key_type>::value),
"key_type must be default constructible");
475 template <
size_type Size>
484 template <
size_type Size>
495 template <
typename TElements,
size_t Size>
498 template <
typename TElements,
size_t Size>
499 const_multiset_ext(
const TElements (&)[Size]) -> const_multiset_ext<TElements>;
505 template <
typename TKey,
typename TKeyCompare>
508 return (lhs.size() == rhs.size()) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
514 template <
typename TKey,
typename TKeyCompare>
517 return !(lhs == rhs);
527 template <
typename TKey,
typename TKeyCompare>
530 return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), lhs.value_comp());
540 template <
typename TKey,
typename TKeyCompare>
554 template <
typename TKey,
typename TKeyCompare>
567 template <
typename TKey,
typename TKeyCompare>
ETL_CONSTEXPR14 const_multiset_ext(const etl::span< const value_type, Size > &sp) ETL_NOEXCEPT
Construct a const_multiset from a variadic list of elements.
Definition const_multiset.h:476
ETL_CONSTEXPR14 const_multiset_ext() ETL_NOEXCEPT
Default construct a const_multiset.
Definition const_multiset.h:467
ETL_CONSTEXPR14 const_multiset_ext(const value_type(&begin_)[Size]) ETL_NOEXCEPT
Construct a const_multiset from an array.
Definition const_multiset.h:485
Multiset type designed for constexpr.
Definition const_multiset.h:400
ETL_CONSTEXPR14 const_multiset(TElements &&... elements) ETL_NOEXCEPT
Construct a const_set from a variadic list of elements. Static asserts if the element type is not con...
Definition const_multiset.h:423
Definition const_multiset.h:55
ETL_CONSTEXPR14 const_iterator cbegin() const ETL_NOEXCEPT
Gets the beginning of the multiset.
Definition const_multiset.h:90
ETL_CONSTEXPR14 size_type size() const ETL_NOEXCEPT
Definition const_multiset.h:312
ETL_CONSTEXPR14 bool is_valid() const ETL_NOEXCEPT
Definition const_multiset.h:72
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_multiset.h:258
ETL_CONSTEXPR14 const_iterator find(const K &key) const ETL_NOEXCEPT
Gets a const_iterator to the value at the key index. Enabled if the comparator is transparent.
Definition const_multiset.h:148
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_multiset.h:285
ETL_CONSTEXPR14 size_type full() const ETL_NOEXCEPT
Definition const_multiset.h:303
ETL_CONSTEXPR14 value_compare value_comp() const ETL_NOEXCEPT
Definition const_multiset.h:349
ETL_CONSTEXPR14 bool contains(const K &key) const ETL_NOEXCEPT
Checks if the multiset contains an element with key. Enabled if the comparator is transparent.
Definition const_multiset.h:177
ETL_CONSTEXPR14 const_iterator find(const key_type &key) const ETL_NOEXCEPT
Gets a const_iterator to the value at the key index.
Definition const_multiset.h:128
ETL_CONSTEXPR14 const_iterator begin() const ETL_NOEXCEPT
Gets the beginning of the multiset.
Definition const_multiset.h:81
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_multiset.h:231
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_multiset.h:216
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_multiset.h:244
ETL_CONSTEXPR14 size_type count(const key_type &key) const ETL_NOEXCEPT
Counts the numbeer elements with key.
Definition const_multiset.h:187
ETL_CONSTEXPR14 const_iterator end() const ETL_NOEXCEPT
Gets the end of the multiset.
Definition const_multiset.h:99
ETL_CONSTEXPR14 key_compare key_comp() const ETL_NOEXCEPT
Definition const_multiset.h:340
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_multiset.h:271
ETL_CONSTEXPR14 iconst_multiset(const value_type *element_list_, size_type size_, size_type max_elements_) ETL_NOEXCEPT
Constructor.
Definition const_multiset.h:360
ETL_CONSTEXPR14 size_type empty() const ETL_NOEXCEPT
Definition const_multiset.h:294
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_multiset.h:201
ETL_CONSTEXPR14 size_type max_size() const ETL_NOEXCEPT
Definition const_multiset.h:321
ETL_CONSTEXPR14 const_iterator cend() const ETL_NOEXCEPT
Gets the end of the multiset.
Definition const_multiset.h:108
ETL_CONSTEXPR14 const_pointer data() const ETL_NOEXCEPT
Gets the beginning of the multiset.
Definition const_multiset.h:117
ETL_CONSTEXPR14 bool contains(const key_type &key) const ETL_NOEXCEPT
Checks if the multiset contains an element with key.
Definition const_multiset.h:165
ETL_CONSTEXPR14 size_type capacity() const ETL_NOEXCEPT
Definition const_multiset.h:331
Span - Fixed Extent.
Definition span.h:208
ETL_NODISCARD ETL_CONSTEXPR14 bool is_sorted(TIterator begin, TIterator end)
Definition algorithm.h:1660
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1081
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1133
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1147
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1093
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1106
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1120