31#ifndef ETL_FLAT_MULTMAP_INCLUDED
32#define ETL_FLAT_MULTMAP_INCLUDED
60 template <
typename TKey,
typename TMapped,
typename TKeyCompare = etl::less<TKey> >
65 typedef ETL_OR_STD::pair<const TKey, TMapped> value_type;
75 typedef TKey key_type;
76 typedef TMapped mapped_type;
77 typedef TKeyCompare key_compare;
78 typedef value_type& reference;
79 typedef const value_type& const_reference;
81 typedef value_type&& rvalue_reference;
83 typedef value_type* pointer;
84 typedef const value_type* const_pointer;
85 typedef size_t size_type;
87 typedef const key_type& const_key_reference;
89 typedef key_type&& rvalue_key_reference;
95 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
96 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
97 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
108 bool operator ()(
const value_type& element, key_type key)
const
110 return comp(element.first, key);
113 bool operator ()(key_type key,
const value_type& element)
const
115 return comp(key, element.first);
208 const_reverse_iterator
rend()
const
226 const_reverse_iterator
crend()
const
238 template <
typename TIterator>
239 void assign(TIterator first, TIterator last)
241#if ETL_IS_DEBUG_BUILD
242 difference_type d = etl::distance(first, last);
248 while (first != last)
260 ETL_OR_STD::pair<iterator, bool>
insert(
const value_type& value)
264 ETL_OR_STD::pair<iterator, bool> result(
end(),
false);
268 value_type* pvalue = storage.
allocate<value_type>();
269 ::new (pvalue) value_type(value);
270 ETL_INCREMENT_DEBUG_COUNT
282 ETL_OR_STD::pair<iterator, bool>
insert(rvalue_reference value)
286 ETL_OR_STD::pair<iterator, bool> result(
end(),
false);
290 value_type* pvalue = storage.
allocate<value_type>();
291 ::new (pvalue) value_type(etl::move(value));
292 ETL_INCREMENT_DEBUG_COUNT
307 return insert(value).first;
319 return insert(etl::move(value)).first;
330 template <
class TIterator>
331 void insert(TIterator first, TIterator last)
333 while (first != last)
343 ETL_OR_STD::pair<iterator, bool>
emplace(
const value_type& value)
351 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const mapped_type& mapped)
356 value_type* pvalue = storage.
allocate<value_type>();
358 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(mapped);
360 ETL_INCREMENT_DEBUG_COUNT
365#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
369 template <
typename ... Args>
370 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key, Args && ... args)
375 value_type* pvalue = storage.
allocate<value_type>();
377 ::new ((
void*)
etl::
addressof(pvalue->second)) mapped_type(
etl::forward<Args>(args)...);
379 ETL_INCREMENT_DEBUG_COUNT
381 return refmap_t::
insert_at(i_element, *pvalue);
388 template <
typename T1>
389 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1)
394 value_type* pvalue = storage.
allocate<value_type>();
396 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1);
398 ETL_INCREMENT_DEBUG_COUNT
406 template <
typename T1,
typename T2>
407 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2)
412 value_type* pvalue = storage.
allocate<value_type>();
414 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2);
416 ETL_INCREMENT_DEBUG_COUNT
424 template <
typename T1,
typename T2,
typename T3>
425 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2,
const T3& value3)
430 value_type* pvalue = storage.
allocate<value_type>();
432 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2, value3);
434 ETL_INCREMENT_DEBUG_COUNT
442 template <
typename T1,
typename T2,
typename T3,
typename T4>
443 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
448 value_type* pvalue = storage.
allocate<value_type>();
450 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4);
452 ETL_INCREMENT_DEBUG_COUNT
464 size_t erase(const_key_reference key)
466 ETL_OR_STD::pair<iterator, iterator> range =
equal_range(key);
468 if (range.first ==
end())
474 size_t d = etl::distance(range.first, range.second);
475 erase(range.first, range.second);
482 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
483 size_t erase(K&& key)
485 ETL_OR_STD::pair<iterator, iterator> range =
equal_range(etl::forward<K>(key));
487 if (range.first ==
end())
493 size_t d = etl::distance(range.first, range.second);
494 erase(range.first, range.second);
506 i_element->~value_type();
508 ETL_DECREMENT_DEBUG_COUNT
518 i_element->~value_type();
520 ETL_DECREMENT_DEBUG_COUNT
540 ETL_DECREMENT_DEBUG_COUNT
567 ETL_RESET_DEBUG_COUNT
583 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
602 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
603 const_iterator
find(
const K& key)
const
614 size_t count(const_key_reference key)
const
621 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
622 size_t count(
const K& key)
const
640 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
659 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
678 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
697 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
709 ETL_OR_STD::pair<iterator, iterator>
equal_range(const_key_reference key)
716 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
717 ETL_OR_STD::pair<iterator, iterator>
equal_range(
const K& key)
728 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(const_key_reference key)
const
735 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
736 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const
752 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
778 move_container(etl::move(rhs));
864 while (first != last)
869 this->
insert(etl::move(*first));
884 ETL_DECLARE_DEBUG_COUNT
889#if defined(ETL_POLYMORPHIC_FLAT_MULTIMAP) || defined(ETL_POLYMORPHIC_CONTAINERS)
909 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
922 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
925 return !(lhs == rhs);
936 template <
typename TKey,
typename TValue, const
size_t MAX_SIZE_,
typename TCompare = etl::less<TKey> >
941 static ETL_CONSTANT
size_t MAX_SIZE = MAX_SIZE_;
969 this->move_container(etl::move(other));
980 template <
typename TIterator>
984 this->
assign(first, last);
987#if ETL_HAS_INITIALIZER_LIST
991 flat_multimap(std::initializer_list<
typename etl::iflat_multimap<TKey, TValue, TCompare>::value_type> init)
994 this->
assign(init.begin(), init.end());
1027 this->move_container(etl::move(rhs));
1036 typedef typename etl::iflat_multimap<TKey, TValue, TCompare>::value_type node_t;
1045 template <
typename TKey,
typename TValue, const
size_t MAX_SIZE_,
typename TCompare>
1046 ETL_CONSTANT
size_t flat_multimap<TKey, TValue, MAX_SIZE_, TCompare>::MAX_SIZE;
1051#if ETL_USING_CPP17 && ETL_HAS_INITIALIZER_LIST
1052 template <
typename... TPairs>
1053 flat_multimap(TPairs...) -> flat_multimap<
typename etl::nth_type_t<0, TPairs...>::first_type,
1054 typename etl::nth_type_t<0, TPairs...>::second_type,
1061#if ETL_USING_CPP11 && ETL_HAS_INITIALIZER_LIST
1062 template <
typename TKey,
typename TMapped,
typename TKeyCompare = etl::less<TKey>,
typename... TPairs>
1063 constexpr auto make_flat_multimap(TPairs&&... pairs) ->
etl::flat_multimap<TKey, TMapped,
sizeof...(TPairs), TKeyCompare>
1065 return { {etl::forward<TPairs>(pairs)...} };
Definition: reference_flat_multimap.h:69
Definition: reference_flat_multimap.h:191
Definition: reference_flat_multimap.h:107
Definition: reference_flat_multimap.h:85
const_reverse_iterator crbegin() const
Definition: reference_flat_multimap.h:423
size_t count(key_parameter_t key) const
Definition: reference_flat_multimap.h:683
ETL_OR_STD::pair< iterator, iterator > equal_range(key_parameter_t key)
Definition: reference_flat_multimap.h:782
iterator lower_bound(key_parameter_t key)
Definition: reference_flat_multimap.h:706
reverse_iterator rbegin()
Definition: reference_flat_multimap.h:387
const_reverse_iterator crend() const
Definition: reference_flat_multimap.h:432
iterator upper_bound(key_parameter_t key)
Definition: reference_flat_multimap.h:744
bool empty() const
Definition: reference_flat_multimap.h:853
const_iterator cbegin() const
Definition: reference_flat_multimap.h:369
size_type size() const
Definition: reference_flat_multimap.h:844
ETL_OR_STD::pair< iterator, bool > insert_at(iterator i_element, value_type &value)
Definition: reference_flat_multimap.h:909
size_t available() const
Definition: reference_flat_multimap.h:889
bool full() const
Definition: reference_flat_multimap.h:862
size_t erase(key_parameter_t key)
Definition: reference_flat_multimap.h:510
iterator begin()
Definition: reference_flat_multimap.h:333
iterator end()
Definition: reference_flat_multimap.h:351
iterator find(key_parameter_t key)
Definition: reference_flat_multimap.h:589
const_iterator cend() const
Definition: reference_flat_multimap.h:378
size_type max_size() const
Definition: reference_flat_multimap.h:880
void clear()
Clears the reference_flat_multimap.
Definition: reference_flat_multimap.h:579
size_type capacity() const
Definition: reference_flat_multimap.h:871
reverse_iterator rend()
Definition: reference_flat_multimap.h:405
#define ETL_ASSERT(b, e)
Definition: error_handler.h:316
const_iterator begin() const
Definition: flat_multimap.h:136
const_reverse_iterator crbegin() const
Definition: flat_multimap.h:217
reverse_iterator rbegin()
Definition: flat_multimap.h:181
iterator end()
Definition: flat_multimap.h:145
size_type capacity() const
Definition: flat_multimap.h:815
size_type size() const
Definition: flat_multimap.h:788
const_iterator cbegin() const
Definition: flat_multimap.h:163
ETL_OR_STD::pair< iterator, bool > emplace(const key_type &key, const T1 &value1, const T2 &value2)
Emplaces a value to the map.
Definition: flat_multimap.h:407
size_t available() const
Definition: flat_multimap.h:833
ETL_OR_STD::pair< const_iterator, const_iterator > equal_range(const_key_reference key) const
Definition: flat_multimap.h:728
flat_multimap(TIterator first, TIterator last)
Definition: flat_multimap.h:981
const_reverse_iterator rbegin() const
Definition: flat_multimap.h:190
bool full() const
Definition: flat_multimap.h:806
const_iterator upper_bound(const_key_reference key) const
Definition: flat_multimap.h:690
size_type max_size() const
Definition: flat_multimap.h:824
size_t erase(const_key_reference key)
Definition: flat_multimap.h:464
size_t count(const_key_reference key) const
Definition: flat_multimap.h:614
const_reverse_iterator rend() const
Definition: flat_multimap.h:208
iterator erase(const_iterator i_element)
Definition: flat_multimap.h:516
iflat_multimap(lookup_t &lookup_, storage_t &storage_)
Constructor.
Definition: flat_multimap.h:843
iterator insert(const_iterator, const value_type &value)
Definition: flat_multimap.h:305
ETL_OR_STD::pair< iterator, bool > emplace(const value_type &value)
Emplaces a value to the map.
Definition: flat_multimap.h:343
const_iterator end() const
Definition: flat_multimap.h:154
iflat_multimap & operator=(const iflat_multimap &rhs)
Assignment operator.
Definition: flat_multimap.h:762
flat_multimap()
Constructor.
Definition: flat_multimap.h:946
const_reverse_iterator crend() const
Definition: flat_multimap.h:226
ETL_OR_STD::pair< iterator, bool > emplace(const key_type &key, const mapped_type &mapped)
Emplaces a value to the map.
Definition: flat_multimap.h:351
bool contains(const_key_reference key) const
Check if the map contains the key.
Definition: flat_multimap.h:745
iterator begin()
Definition: flat_multimap.h:127
const_iterator cend() const
Definition: flat_multimap.h:172
void clear()
Clears the flat_multimap.
Definition: flat_multimap.h:549
ETL_OR_STD::pair< iterator, bool > emplace(const key_type &key, const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Emplaces a value to the map.
Definition: flat_multimap.h:443
reverse_iterator rend()
Definition: flat_multimap.h:199
iterator erase(const_iterator first, const_iterator last)
Definition: flat_multimap.h:531
~flat_multimap()
Destructor.
Definition: flat_multimap.h:1001
ETL_OR_STD::pair< iterator, iterator > equal_range(const_key_reference key)
Definition: flat_multimap.h:709
void assign(TIterator first, TIterator last)
Definition: flat_multimap.h:239
iterator upper_bound(const_key_reference key)
Definition: flat_multimap.h:671
ETL_OR_STD::pair< iterator, bool > emplace(const key_type &key, const T1 &value1, const T2 &value2, const T3 &value3)
Emplaces a value to the map.
Definition: flat_multimap.h:425
ETL_OR_STD::pair< iterator, bool > insert(const value_type &value)
Definition: flat_multimap.h:260
const_iterator find(const_key_reference key) const
Definition: flat_multimap.h:595
const_iterator lower_bound(const_key_reference key) const
Definition: flat_multimap.h:652
~iflat_multimap()
Internal debugging.
Definition: flat_multimap.h:896
flat_multimap(const flat_multimap &other)
Copy constructor.
Definition: flat_multimap.h:954
bool empty() const
Definition: flat_multimap.h:797
void insert(TIterator first, TIterator last)
Definition: flat_multimap.h:331
ETL_OR_STD::pair< iterator, bool > emplace(const key_type &key, const T1 &value1)
Emplaces a value to the map.
Definition: flat_multimap.h:389
iterator find(const_key_reference key)
Definition: flat_multimap.h:576
iterator lower_bound(const_key_reference key)
Definition: flat_multimap.h:633
iterator erase(iterator i_element)
Definition: flat_multimap.h:504
Definition: flat_multimap.h:938
Definition: flat_multimap.h:62
ETL_CONSTEXPR17 T * addressof(T &t)
Definition: addressof.h:51
void release_all()
Release all objects in the pool.
Definition: ipool.h:248
T * allocate()
Definition: ipool.h:113
void release(const void *const p_object)
Definition: ipool.h:239
bitset_ext
Definition: absolute.h:38
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:645
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:633
Definition: type_traits_generator.h:2055
iterator
Definition: iterator.h:399