31 #ifndef ETL_FLAT_MULTMAP_INCLUDED
32 #define ETL_FLAT_MULTMAP_INCLUDED
40 #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
41 #include <initializer_list>
62 template <
typename TKey,
typename TMapped,
typename TKeyCompare = etl::less<TKey> >
67 typedef ETL_OR_STD::pair<const TKey, TMapped> value_type;
77 typedef TKey key_type;
78 typedef TMapped mapped_type;
79 typedef TKeyCompare key_compare;
80 typedef value_type& reference;
81 typedef const value_type& const_reference;
82 #if ETL_CPP11_SUPPORTED
83 typedef value_type&& rvalue_reference;
85 typedef value_type* pointer;
86 typedef const value_type* const_pointer;
87 typedef size_t size_type;
92 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
93 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
94 typedef typename etl::iterator_traits<iterator>::difference_type difference_type;
98 typedef const key_type& key_parameter_t;
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);
209 const_reverse_iterator
rend()
const
227 const_reverse_iterator
crend()
const
239 template <
typename TIterator>
240 void assign(TIterator first, TIterator last)
242 #if defined(ETL_DEBUG)
243 difference_type d = etl::distance(first, last);
249 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
276 #if ETL_CPP11_SUPPORTED
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;
310 #if ETL_CPP11_SUPPORTED
319 return insert(etl::move(value)).first;
330 template <
class TIterator>
331 void insert(TIterator first, TIterator last)
333 while (first != last)
342 ETL_OR_STD::pair<iterator, bool>
emplace(
const value_type& value)
350 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const mapped_type& value)
355 value_type* pvalue = storage.
allocate<value_type>();
359 ETL_INCREMENT_DEBUG_COUNT
364 #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT
368 template <
typename ... Args>
369 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key, Args && ... args)
374 value_type* pvalue = storage.
allocate<value_type>();
376 ::new ((
void*)
etl::
addressof(pvalue->second)) mapped_type(
etl::forward<Args>(args)...);
378 ETL_INCREMENT_DEBUG_COUNT
380 return refmap_t::
insert_at(i_element, *pvalue);
387 template <
typename T1>
388 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1)
393 value_type* pvalue = storage.
allocate<value_type>();
395 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1);
397 ETL_INCREMENT_DEBUG_COUNT
405 template <
typename T1,
typename T2>
406 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2)
411 value_type* pvalue = storage.
allocate<value_type>();
413 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2);
415 ETL_INCREMENT_DEBUG_COUNT
423 template <
typename T1,
typename T2,
typename T3>
424 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2,
const T3& value3)
429 value_type* pvalue = storage.
allocate<value_type>();
431 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2, value3);
433 ETL_INCREMENT_DEBUG_COUNT
441 template <
typename T1,
typename T2,
typename T3,
typename T4>
442 ETL_OR_STD::pair<iterator, bool>
emplace(
const key_type& key,
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
447 value_type* pvalue = storage.
allocate<value_type>();
449 ::new ((
void*)
etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4);
451 ETL_INCREMENT_DEBUG_COUNT
465 ETL_OR_STD::pair<iterator, iterator> range =
equal_range(key);
467 if (range.first ==
end())
473 size_t d = etl::distance(range.first, range.second);
474 erase(range.first, range.second);
485 i_element->~value_type();
488 ETL_DECREMENT_DEBUG_COUNT
507 ETL_DECREMENT_DEBUG_COUNT
534 ETL_RESET_DEBUG_COUNT
563 size_t count(key_parameter_t key)
const
613 ETL_OR_STD::pair<iterator, iterator>
equal_range(key_parameter_t key)
623 ETL_OR_STD::pair<const_iterator, const_iterator>
equal_range(key_parameter_t key)
const
641 #if ETL_CPP11_SUPPORTED
647 move_container(etl::move(rhs));
718 #if ETL_CPP11_SUPPORTED
733 while (first != last)
735 this->
insert(etl::move(*first++));
749 ETL_DECLARE_DEBUG_COUNT
754 #if defined(ETL_POLYMORPHIC_FLAT_MULTIMAP) || defined(ETL_POLYMORPHIC_CONTAINERS)
774 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
787 template <
typename TKey,
typename TMapped,
typename TKeyCompare>
790 return !(lhs == rhs);
801 template <
typename TKey,
typename TValue, const
size_t MAX_SIZE_,
typename TCompare = etl::less<TKey> >
806 static const size_t MAX_SIZE = MAX_SIZE_;
825 #if ETL_CPP11_SUPPORTED
834 this->move_container(etl::move(other));
845 template <
typename TIterator>
849 this->
assign(first, last);
852 #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
856 flat_multimap(std::initializer_list<
typename etl::iflat_multimap<TKey, TValue, TCompare>::value_type> init)
859 this->
assign(init.begin(), init.end());
884 #if ETL_CPP11_SUPPORTED
892 this->move_container(etl::move(rhs));
901 typedef typename etl::iflat_multimap<TKey, TValue, TCompare>::value_type node_t;
913 #if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
914 template <
typename T,
typename... Ts>
915 flat_multimap(T, Ts...)
916 ->flat_multimap<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...),
typename T::first_type>,
917 etl::enable_if_t<(etl::is_same_v<T, Ts> && ...),
typename T::second_type>,
Definition: reference_flat_multimap.h:67
Definition: reference_flat_multimap.h:204
Definition: reference_flat_multimap.h:105
Definition: reference_flat_multimap.h:83
const_reverse_iterator crbegin() const
Definition: reference_flat_multimap.h:422
size_t count(key_parameter_t key) const
Definition: reference_flat_multimap.h:605
iterator lower_bound(key_parameter_t key)
Definition: reference_flat_multimap.h:617
reverse_iterator rbegin()
Definition: reference_flat_multimap.h:386
const_reverse_iterator crend() const
Definition: reference_flat_multimap.h:431
iterator upper_bound(key_parameter_t key)
Definition: reference_flat_multimap.h:637
bool empty() const
Definition: reference_flat_multimap.h:689
const_iterator cbegin() const
Definition: reference_flat_multimap.h:368
size_type size() const
Definition: reference_flat_multimap.h:680
ETL_OR_STD::pair< iterator, iterator > equal_range(key_parameter_t key)
Definition: reference_flat_multimap.h:657
size_t available() const
Definition: reference_flat_multimap.h:725
bool full() const
Definition: reference_flat_multimap.h:698
size_t erase(key_parameter_t key)
Definition: reference_flat_multimap.h:507
ETL_OR_STD::pair< iterator, bool > insert_at(iterator i_element, value_type &value)
Definition: reference_flat_multimap.h:745
iterator begin()
Definition: reference_flat_multimap.h:332
iterator end()
Definition: reference_flat_multimap.h:350
iterator find(key_parameter_t key)
Definition: reference_flat_multimap.h:557
const_iterator cend() const
Definition: reference_flat_multimap.h:377
size_type max_size() const
Definition: reference_flat_multimap.h:716
void clear()
Clears the reference_flat_multimap.
Definition: reference_flat_multimap.h:547
size_type capacity() const
Definition: reference_flat_multimap.h:707
reverse_iterator rend()
Definition: reference_flat_multimap.h:404
#define ETL_ASSERT(b, e)
Definition: error_handler.h:290
const_iterator begin() const
Definition: flat_multimap.h:137
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:406
const_reverse_iterator crbegin() const
Definition: flat_multimap.h:218
reverse_iterator rbegin()
Definition: flat_multimap.h:182
iterator end()
Definition: flat_multimap.h:146
size_type capacity() const
Definition: flat_multimap.h:684
size_type size() const
Definition: flat_multimap.h:657
const_iterator cbegin() const
Definition: flat_multimap.h:164
iterator find(key_parameter_t key)
Definition: flat_multimap.h:543
const_iterator upper_bound(key_parameter_t key) const
Definition: flat_multimap.h:603
size_t available() const
Definition: flat_multimap.h:702
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:442
flat_multimap(TIterator first, TIterator last)
Definition: flat_multimap.h:846
const_reverse_iterator rbegin() const
Definition: flat_multimap.h:191
ETL_OR_STD::pair< iterator, bool > emplace(const key_type &key, const T1 &value1)
Emplaces a value to the map.
Definition: flat_multimap.h:388
bool full() const
Definition: flat_multimap.h:675
const_iterator find(key_parameter_t key) const
Definition: flat_multimap.h:553
size_type max_size() const
Definition: flat_multimap.h:693
iflat_multimap & operator=(const iflat_multimap &rhs)
Assignment operator.
Definition: flat_multimap.h:631
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:424
iterator upper_bound(key_parameter_t key)
Definition: flat_multimap.h:593
const_reverse_iterator rend() const
Definition: flat_multimap.h:209
iflat_multimap(lookup_t &lookup_, storage_t &storage_)
Constructor.
Definition: flat_multimap.h:712
size_t erase(key_parameter_t key)
Definition: flat_multimap.h:463
const_iterator end() const
Definition: flat_multimap.h:155
ETL_OR_STD::pair< const_iterator, const_iterator > equal_range(key_parameter_t key) const
Definition: flat_multimap.h:623
flat_multimap()
Constructor.
Definition: flat_multimap.h:811
const_reverse_iterator crend() const
Definition: flat_multimap.h:227
iterator insert(iterator position, const value_type &value)
Definition: flat_multimap.h:305
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:516
reverse_iterator rend()
Definition: flat_multimap.h:200
ETL_OR_STD::pair< iterator, iterator > equal_range(key_parameter_t key)
Definition: flat_multimap.h:613
const_iterator lower_bound(key_parameter_t key) const
Definition: flat_multimap.h:583
~flat_multimap()
Destructor.
Definition: flat_multimap.h:866
void assign(TIterator first, TIterator last)
Definition: flat_multimap.h:240
void erase(iterator i_element)
Definition: flat_multimap.h:483
~iflat_multimap()
Internal debugging.
Definition: flat_multimap.h:761
ETL_OR_STD::pair< iterator, bool > insert(const value_type &value)
Definition: flat_multimap.h:260
void erase(iterator first, iterator last)
Definition: flat_multimap.h:498
flat_multimap(const flat_multimap &other)
Copy constructor.
Definition: flat_multimap.h:819
iterator lower_bound(key_parameter_t key)
Definition: flat_multimap.h:573
bool empty() const
Definition: flat_multimap.h:666
ETL_OR_STD::pair< iterator, bool > emplace(const key_type &key, const mapped_type &value)
Emplaces a value to the map.
Definition: flat_multimap.h:350
ETL_OR_STD::pair< iterator, bool > emplace(const value_type &value)
Emplaces a value to the map.
Definition: flat_multimap.h:342
void insert(TIterator first, TIterator last)
Definition: flat_multimap.h:331
size_t count(key_parameter_t key) const
Definition: flat_multimap.h:563
Definition: flat_multimap.h:803
Definition: flat_multimap.h:64
T * addressof(T &t)
Definition: memory.h:61
void release_all()
Release all objects in the pool.
Definition: pool.h:264
void release(const void *const p_object)
Definition: pool.h:255
T * allocate()
Definition: pool.h:129
is_trivially_destructible
Definition: type_traits_generator.h:1171
Definition: absolute.h:37
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:594
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:582
iterator
Definition: iterator.h:422