31#ifndef ETL_FLAT_MULTMAP_INCLUDED
32#define ETL_FLAT_MULTMAP_INCLUDED
61 template <
typename TKey,
typename TMapped,
typename TKeyCompare = etl::less<TKey> >
66 typedef ETL_OR_STD::pair<const TKey, TMapped> value_type;
71 typedef typename refmap_t::lookup_t lookup_t;
76 typedef TKey key_type;
77 typedef TMapped mapped_type;
78 typedef TKeyCompare key_compare;
79 typedef value_type& reference;
80 typedef const value_type& const_reference;
82 typedef value_type&& rvalue_reference;
84 typedef value_type* pointer;
85 typedef const value_type* const_pointer;
86 typedef size_t size_type;
88 typedef const key_type& const_key_reference;
90 typedef key_type&& rvalue_key_reference;
93 typedef typename refmap_t::iterator iterator;
94 typedef typename refmap_t::const_iterator const_iterator;
96 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
97 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
98 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
109 bool operator()(
const value_type& element, key_type key)
const
111 return comp(element.first, key);
114 bool operator()(key_type key,
const value_type& element)
const
116 return comp(key, element.first);
155 const_iterator
end()
const
211 const_reverse_iterator
rend()
const
231 const_reverse_iterator
crend()
const
244 template <
typename TIterator>
245 void assign(TIterator first, TIterator last)
247#if ETL_IS_DEBUG_BUILD
248 difference_type d = etl::distance(first, last);
254 while (first != last)
267 ETL_OR_STD::pair<iterator, bool>
insert(
const value_type& value)
271 ETL_OR_STD::pair<iterator, bool> result(
end(),
false);
275 value_type* pvalue = storage.allocate<value_type>();
276 ::new (pvalue) value_type(value);
277 ETL_INCREMENT_DEBUG_COUNT;
290 ETL_OR_STD::pair<iterator, bool>
insert(rvalue_reference value)
294 ETL_OR_STD::pair<iterator, bool> result(
end(),
false);
300 ETL_INCREMENT_DEBUG_COUNT;
314 iterator
insert(const_iterator ,
const value_type& value)
316 return insert(value).first;
329 return insert(etl::move(value)).first;
341 template <
class TIterator>
342 void insert(TIterator first, TIterator last)
344 while (first != last)
354 ETL_OR_STD::pair<iterator, bool>
emplace(
const value_type& value)
362 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const mapped_type& mapped)
367 value_type* pvalue = storage.allocate<value_type>();
369 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(mapped);
371 ETL_INCREMENT_DEBUG_COUNT;
376#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT
380 template <
typename... Args>
381 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key, Args&&... args)
388 ::new ((
void*)
etl::
addressof(pvalue->second)) mapped_type(
etl::forward<Args>(args)...);
389 iterator i_element = upper_bound(key);
390 ETL_INCREMENT_DEBUG_COUNT;
392 return refmap_t::
insert_at(i_element, *pvalue);
399 template <
typename T1>
400 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1)
405 value_type* pvalue = storage.allocate<value_type>();
407 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1);
409 ETL_INCREMENT_DEBUG_COUNT;
417 template <
typename T1,
typename T2>
418 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2)
423 value_type* pvalue = storage.allocate<value_type>();
425 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2);
427 ETL_INCREMENT_DEBUG_COUNT;
435 template <
typename T1,
typename T2,
typename T3>
436 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2,
const T3& value3)
441 value_type* pvalue = storage.allocate<value_type>();
443 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2, value3);
445 ETL_INCREMENT_DEBUG_COUNT;
453 template <
typename T1,
typename T2,
typename T3,
typename T4>
454 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
459 value_type* pvalue = storage.allocate<value_type>();
461 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4);
463 ETL_INCREMENT_DEBUG_COUNT;
475 size_t erase(const_key_reference key)
477 ETL_OR_STD::pair<iterator, iterator> range =
equal_range(key);
479 if (range.first ==
end())
485 size_t d =
static_cast<size_t>(etl::distance(range.first, range.second));
486 erase(range.first, range.second);
493 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
494 size_t erase(K&& key)
496 ETL_OR_STD::pair<iterator, iterator> range =
equal_range(etl::forward<K>(key));
498 if (range.first ==
end())
504 size_t d =
static_cast<size_t>(etl::distance(range.first, range.second));
505 erase(range.first, range.second);
517 i_element->~value_type();
519 ETL_DECREMENT_DEBUG_COUNT;
527 iterator
erase(const_iterator i_element)
529 i_element->~value_type();
531 ETL_DECREMENT_DEBUG_COUNT;
542 iterator
erase(const_iterator first, const_iterator last)
544 const_iterator itr = first;
551 ETL_DECREMENT_DEBUG_COUNT;
562 if ETL_IF_CONSTEXPR (etl::is_trivially_destructible<value_type>::value)
564 storage.release_all();
568 iterator itr =
begin();
578 ETL_RESET_DEBUG_COUNT;
587 iterator
find(const_key_reference key)
594 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
606 const_iterator
find(const_key_reference key)
const
613 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
625 size_t count(const_key_reference key)
const
632 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
633 size_t count(
const K& key)
const
651 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
670 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
689 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
708 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
720 ETL_OR_STD::pair<iterator, iterator>
equal_range(const_key_reference key)
727 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
728 ETL_OR_STD::pair<iterator, iterator>
equal_range(
const K& key)
739 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(const_key_reference key)
const
746 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
747 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(
const K& key)
const
763 template <typename K, typename KC = TKeyCompare, etl::enable_if_t<comparator_is_transparent<KC>::value,
int> = 0>
789 move_container(etl::move(rhs));
871 etl::iflat_multimap<TKey, TMapped, TKeyCompare>::iterator first = rhs.begin();
872 etl::iflat_multimap<TKey, TMapped, TKeyCompare>::iterator last = rhs.end();
875 while (first != last)
877 typename etl::iflat_multimap<TKey, TMapped, TKeyCompare>::iterator temp = first;
880 this->
insert(etl::move(*first));
895 ETL_DECLARE_DEBUG_COUNT;
900#if defined(ETL_POLYMORPHIC_FLAT_MULTIMAP) || defined(ETL_POLYMORPHIC_CONTAINERS)
920 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
933 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
936 return !(lhs == rhs);
947 template <
typename TKey,
typename TValue, const
size_t MAX_SIZE_,
typename TCompare = etl::less<TKey> >
952 static ETL_CONSTANT
size_t MAX_SIZE = MAX_SIZE_;
980 this->move_container(etl::move(other));
991 template <
typename TIterator>
995 this->
assign(first, last);
998#if ETL_HAS_INITIALIZER_LIST
1002 flat_multimap(std::initializer_list<
typename etl::iflat_multimap<TKey, TValue, TCompare>::value_type> init)
1005 this->assign(init.begin(), init.end());
1038 this->move_container(etl::move(rhs));
1047 typedef typename etl::iflat_multimap<TKey, TValue, TCompare>::value_type node_t;
1050 etl::pool<node_t, MAX_SIZE> storage;
1053 etl::vector<node_t*, MAX_SIZE> lookup;
1056 template <
typename TKey,
typename TValue, const
size_t MAX_SIZE_,
typename TCompare>
1057 ETL_CONSTANT
size_t flat_multimap<TKey, TValue, MAX_SIZE_, TCompare>::MAX_SIZE;
1062#if ETL_USING_CPP17 && ETL_HAS_INITIALIZER_LIST
1063 template <
typename... TPairs>
1064 flat_multimap(TPairs...)
1065 -> flat_multimap<
typename etl::nth_type_t<0, TPairs...>::first_type,
typename etl::nth_type_t<0, TPairs...>::second_type,
sizeof...(TPairs)>;
1071#if ETL_USING_CPP11 && ETL_HAS_INITIALIZER_LIST
1072 template <
typename TKey,
typename TMapped,
typename TKeyCompare = etl::less<TKey>,
typename... TPairs>
1073 constexpr auto make_flat_multimap(TPairs&&... pairs) -> etl::flat_multimap<TKey, TMapped,
sizeof...(TPairs), TKeyCompare>
1075 return {etl::forward<TPairs>(pairs)...};
Definition reference_flat_multimap.h:68
Definition reference_flat_multimap.h:85
const_reverse_iterator crbegin() const
Definition reference_flat_multimap.h:429
size_t count(key_parameter_t key) const
Definition reference_flat_multimap.h:696
ETL_OR_STD::pair< iterator, iterator > equal_range(key_parameter_t key)
Definition reference_flat_multimap.h:795
iterator lower_bound(key_parameter_t key)
Definition reference_flat_multimap.h:719
reverse_iterator rbegin()
Definition reference_flat_multimap.h:386
const_reverse_iterator crend() const
Definition reference_flat_multimap.h:440
iterator upper_bound(key_parameter_t key)
Definition reference_flat_multimap.h:757
bool empty() const
Definition reference_flat_multimap.h:866
const_iterator cbegin() const
Definition reference_flat_multimap.h:367
size_type size() const
Definition reference_flat_multimap.h:857
ETL_OR_STD::pair< iterator, bool > insert_at(iterator i_element, value_type &value)
Definition reference_flat_multimap.h:922
size_t available() const
Definition reference_flat_multimap.h:902
bool full() const
Definition reference_flat_multimap.h:875
size_t erase(key_parameter_t key)
Definition reference_flat_multimap.h:523
iterator begin()
Definition reference_flat_multimap.h:329
iterator end()
Definition reference_flat_multimap.h:348
iterator find(key_parameter_t key)
Definition reference_flat_multimap.h:602
const_iterator cend() const
Definition reference_flat_multimap.h:376
size_type max_size() const
Definition reference_flat_multimap.h:893
void clear()
Definition reference_flat_multimap.h:592
size_type capacity() const
Definition reference_flat_multimap.h:884
reverse_iterator rend()
Definition reference_flat_multimap.h:407
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
const_iterator begin() const
Definition flat_multimap.h:137
const_reverse_iterator crbegin() const
Definition flat_multimap.h:222
reverse_iterator rbegin()
Definition flat_multimap.h:183
iterator end()
Definition flat_multimap.h:146
flat_multimap & operator=(const flat_multimap &rhs)
Assignment operator.
Definition flat_multimap.h:1020
size_type capacity() const
Definition flat_multimap.h:826
size_type size() const
Definition flat_multimap.h:799
const_iterator cbegin() const
Definition flat_multimap.h:164
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:418
size_t available() const
Definition flat_multimap.h:844
ETL_OR_STD::pair< const_iterator, const_iterator > equal_range(const_key_reference key) const
Definition flat_multimap.h:739
flat_multimap(TIterator first, TIterator last)
Definition flat_multimap.h:992
const_reverse_iterator rbegin() const
Definition flat_multimap.h:193
bool full() const
Definition flat_multimap.h:817
const_iterator upper_bound(const_key_reference key) const
Definition flat_multimap.h:701
size_type max_size() const
Definition flat_multimap.h:835
size_t erase(const_key_reference key)
Definition flat_multimap.h:475
size_t count(const_key_reference key) const
Definition flat_multimap.h:625
const_reverse_iterator rend() const
Definition flat_multimap.h:211
iterator erase(const_iterator i_element)
Definition flat_multimap.h:527
iflat_multimap(lookup_t &lookup_, storage_t &storage_)
Constructor.
Definition flat_multimap.h:854
iterator insert(const_iterator, const value_type &value)
Definition flat_multimap.h:314
ETL_OR_STD::pair< iterator, bool > emplace(const value_type &value)
Emplaces a value to the map.
Definition flat_multimap.h:354
const_iterator end() const
Definition flat_multimap.h:155
iflat_multimap & operator=(const iflat_multimap &rhs)
Assignment operator.
Definition flat_multimap.h:773
flat_multimap()
Constructor.
Definition flat_multimap.h:957
const_reverse_iterator crend() const
Definition flat_multimap.h:231
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:362
bool contains(const_key_reference key) const
Check if the map contains the key.
Definition flat_multimap.h:756
iterator begin()
Definition flat_multimap.h:128
const_iterator cend() const
Definition flat_multimap.h:173
void clear()
Clears the flat_multimap.
Definition flat_multimap.h:560
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:454
reverse_iterator rend()
Definition flat_multimap.h:202
iterator erase(const_iterator first, const_iterator last)
Definition flat_multimap.h:542
~flat_multimap()
Destructor.
Definition flat_multimap.h:1012
ETL_OR_STD::pair< iterator, iterator > equal_range(const_key_reference key)
Definition flat_multimap.h:720
void assign(TIterator first, TIterator last)
Definition flat_multimap.h:245
iterator upper_bound(const_key_reference key)
Definition flat_multimap.h:682
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:436
ETL_OR_STD::pair< iterator, bool > insert(const value_type &value)
Definition flat_multimap.h:267
const_iterator find(const_key_reference key) const
Definition flat_multimap.h:606
const_iterator lower_bound(const_key_reference key) const
Definition flat_multimap.h:663
~iflat_multimap()
Destructor.
Definition flat_multimap.h:909
flat_multimap(const flat_multimap &other)
Copy constructor.
Definition flat_multimap.h:965
bool empty() const
Definition flat_multimap.h:808
void insert(TIterator first, TIterator last)
Definition flat_multimap.h:342
ETL_OR_STD::pair< iterator, bool > emplace(const key_type &key, const T1 &value1)
Emplaces a value to the map.
Definition flat_multimap.h:400
iterator find(const_key_reference key)
Definition flat_multimap.h:587
iterator lower_bound(const_key_reference key)
Definition flat_multimap.h:644
iterator erase(iterator i_element)
Definition flat_multimap.h:515
Definition flat_multimap.h:949
Definition flat_multimap.h:63
ETL_CONSTEXPR17 etl::enable_if<!etl::is_same< T, etl::nullptr_t >::value, T >::type * addressof(T &t)
Definition addressof.h:52
T * allocate()
Definition ipool.h:333
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
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1093
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:997
iterator
Definition iterator.h:424