tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
flat_multiset.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_FLAT_SET_FLAT_MULTISET_HPP
4#define TETL_FLAT_SET_FLAT_MULTISET_HPP
5
6#include <etl/_config/all.hpp>
7
12#include <etl/_utility/move.hpp>
13
14namespace etl {
15
16template <typename Key, typename KeyContainer, typename Compare = less<Key>>
18 using key_type = Key;
19 using value_type = Key;
20 using key_compare = Compare;
21 using value_compare = Compare;
24 using size_type = typename KeyContainer::size_type;
25 using difference_type = typename KeyContainer::difference_type;
26 using iterator = typename KeyContainer::iterator;
27 using const_iterator = typename KeyContainer::const_iterator;
30 using container_type = KeyContainer;
31
32 constexpr flat_multiset()
33 : flat_multiset(Compare())
34 {
35 }
36
37 explicit constexpr flat_multiset(Compare const& comp)
38 : _container()
39 , _compare(comp)
40 {
41 }
42
43 explicit constexpr flat_multiset(KeyContainer cont)
45 {
46 etl::sort(begin(), end(), _compare);
47 }
48
49 constexpr flat_multiset(sorted_equivalent_t /*tag*/, KeyContainer cont)
50 : _container(etl::move(cont))
51 , _compare()
52 {
53 }
54
55 [[nodiscard]] constexpr auto begin() noexcept -> iterator { return _container.begin(); }
56 [[nodiscard]] constexpr auto begin() const noexcept -> const_iterator { return _container.begin(); }
57 [[nodiscard]] constexpr auto cbegin() const noexcept -> const_iterator { return _container.begin(); }
58
59 [[nodiscard]] constexpr auto end() noexcept -> iterator { return _container.end(); }
60 [[nodiscard]] constexpr auto end() const noexcept -> const_iterator { return _container.end(); }
61 [[nodiscard]] constexpr auto cend() const noexcept -> const_iterator { return _container.end(); }
62
63 [[nodiscard]] constexpr auto rbegin() noexcept -> reverse_iterator { return _container.rbegin(); }
64 [[nodiscard]] constexpr auto rbegin() const noexcept -> const_reverse_iterator { return _container.rbegin(); }
65 [[nodiscard]] constexpr auto crbegin() const noexcept -> const_reverse_iterator { return _container.crbegin(); }
66
67 [[nodiscard]] constexpr auto rend() noexcept -> reverse_iterator { return _container.rend(); }
68 [[nodiscard]] constexpr auto rend() const noexcept -> const_reverse_iterator { return _container.rend(); }
69 [[nodiscard]] constexpr auto crend() const noexcept -> const_reverse_iterator { return _container.crend(); }
70
71 [[nodiscard]] constexpr auto empty() const noexcept -> bool { return _container.empty(); }
72 [[nodiscard]] constexpr auto size() const noexcept -> size_type { return _container.size(); }
73 [[nodiscard]] constexpr auto max_size() const noexcept -> size_type { return _container.max_size(); }
74
75private:
76 TETL_NO_UNIQUE_ADDRESS KeyContainer _container;
77 TETL_NO_UNIQUE_ADDRESS Compare _compare;
78};
79
80} // namespace etl
81
82#endif // TETL_FLAT_SET_FLAT_MULTISET_HPP
#define TETL_NO_UNIQUE_ADDRESS
Definition attributes.hpp:41
constexpr auto move(InputIt first, InputIt last, OutputIt destination) -> OutputIt
Moves the elements in the range [first, last), to another range beginning at destination,...
Definition move.hpp:26
constexpr auto sort(RandomIt first, RandomIt last, Compare comp) -> void
Sorts the elements in the range [first, last) in non-descending order. The order of equal elements is...
Definition sort.hpp:18
Definition adjacent_find.hpp:8
constexpr auto sorted_equivalent
Definition sorted_equivalent.hpp:12
Compare value_compare
Definition flat_multiset.hpp:21
Compare key_compare
Definition flat_multiset.hpp:20
constexpr auto crbegin() const noexcept -> const_reverse_iterator
Definition flat_multiset.hpp:65
etl::reverse_iterator< const_iterator > const_reverse_iterator
Definition flat_multiset.hpp:29
value_type const & const_reference
Definition flat_multiset.hpp:23
constexpr auto rbegin() const noexcept -> const_reverse_iterator
Definition flat_multiset.hpp:64
constexpr flat_multiset(Compare const &comp)
Definition flat_multiset.hpp:37
typename KeyContainer::size_type size_type
Definition flat_multiset.hpp:24
Key value_type
Definition flat_multiset.hpp:19
constexpr auto rend() noexcept -> reverse_iterator
Definition flat_multiset.hpp:67
value_type & reference
Definition flat_multiset.hpp:22
constexpr auto begin() noexcept -> iterator
Definition flat_multiset.hpp:55
constexpr auto end() noexcept -> iterator
Definition flat_multiset.hpp:59
constexpr auto begin() const noexcept -> const_iterator
Definition flat_multiset.hpp:56
constexpr auto cbegin() const noexcept -> const_iterator
Definition flat_multiset.hpp:57
constexpr flat_multiset()
Definition flat_multiset.hpp:32
constexpr auto empty() const noexcept -> bool
Definition flat_multiset.hpp:71
etl::reverse_iterator< iterator > reverse_iterator
Definition flat_multiset.hpp:28
typename KeyContainer::const_iterator const_iterator
Definition flat_multiset.hpp:27
constexpr flat_multiset(sorted_equivalent_t, KeyContainer cont)
Definition flat_multiset.hpp:49
constexpr auto max_size() const noexcept -> size_type
Definition flat_multiset.hpp:73
constexpr auto end() const noexcept -> const_iterator
Definition flat_multiset.hpp:60
Key key_type
Definition flat_multiset.hpp:18
constexpr auto crend() const noexcept -> const_reverse_iterator
Definition flat_multiset.hpp:69
KeyContainer container_type
Definition flat_multiset.hpp:30
typename KeyContainer::difference_type difference_type
Definition flat_multiset.hpp:25
constexpr auto rend() const noexcept -> const_reverse_iterator
Definition flat_multiset.hpp:68
constexpr auto size() const noexcept -> size_type
Definition flat_multiset.hpp:72
typename KeyContainer::iterator iterator
Definition flat_multiset.hpp:26
constexpr auto cend() const noexcept -> const_iterator
Definition flat_multiset.hpp:61
constexpr flat_multiset(KeyContainer cont)
Definition flat_multiset.hpp:43
constexpr auto rbegin() noexcept -> reverse_iterator
Definition flat_multiset.hpp:63
reverse_iterator is an iterator adaptor that reverses the direction of a given iterator....
Definition reverse_iterator.hpp:22
Definition sorted_equivalent.hpp:8