3#ifndef TETL_SET_STATIC_SET_HPP
4#define TETL_SET_STATIC_SET_HPP
28template <
typename Key,
size_t Capacity,
typename Compare = less<Key>>
40 storage_type _storage{};
64 template <
typename InputIt>
65 requires(detail::InputIterator<InputIt>)
68 if constexpr (detail::RandomAccessIterator<InputIt>) {
90 [[nodiscard]]
constexpr auto begin() noexcept ->
iterator {
return _storage.begin(); }
100 [[nodiscard]]
constexpr auto end() noexcept ->
iterator {
return _storage.end(); }
145 [[nodiscard]]
constexpr auto empty() const noexcept ->
bool {
return _storage.empty(); }
148 [[nodiscard]]
constexpr auto full() const noexcept ->
bool {
return _storage.full(); }
152 [[nodiscard]]
constexpr auto size() const noexcept ->
size_type {
return _storage.size(); }
156 [[nodiscard]]
constexpr auto max_size() const noexcept ->
size_type {
return _storage.max_size(); }
160 constexpr auto clear() noexcept ->
void { _storage.clear(); }
170 if (p == _storage.end() || *(p) != value) {
172 auto* pos =
rotate(p, _storage.end() - 1, _storage.end());
193 template <
typename InputIter>
194 requires(detail::InputIterator<InputIter>)
197 for (; first != last; ++first) {
205 template <
typename... Args>
228 for (; first != last; ++first) {
266 template <
typename K>
267 requires(detail::is_transparent_v<key_compare>)
293 template <
typename K>
294 requires(detail::is_transparent_v<key_compare>)
305 template <
typename K>
306 requires(detail::is_transparent_v<key_compare>)
321 template <
typename K>
322 requires(detail::is_transparent_v<key_compare>)
323 [[nodiscard]]
constexpr auto contains(K
const& x)
const ->
bool
344 template <
typename K>
345 requires(detail::is_transparent_v<key_compare>)
353 template <
typename K>
354 requires(detail::is_transparent_v<key_compare>)
376 template <
typename K>
377 requires(detail::is_transparent_v<key_compare>)
385 template <
typename K>
386 requires(detail::is_transparent_v<key_compare>)
417 template <
typename K>
418 requires(detail::is_transparent_v<key_compare>)
429 template <
typename K>
430 requires(detail::is_transparent_v<key_compare>)
455template <
typename Key,
size_t Capacity,
typename Comp>
456[[nodiscard]]
constexpr auto
467template <
typename Key,
size_t Capacity,
typename Comp>
468[[nodiscard]]
constexpr auto
471 return !(lhs == rhs);
480template <
typename Key,
size_t Capacity,
typename Comp>
481[[nodiscard]]
constexpr auto
493template <
typename Key,
size_t Capacity,
typename Comp>
494[[nodiscard]]
constexpr auto
506template <
typename Key,
size_t Capacity,
typename Comp>
507[[nodiscard]]
constexpr auto
519template <
typename Key,
size_t Capacity,
typename Comp>
520[[nodiscard]]
constexpr auto
528template <
typename Key,
size_t Capacity,
typename Compare>
530 noexcept(
noexcept(lhs.swap(rhs))) ->
void
#define TETL_PRECONDITION(...)
Definition check.hpp:16
constexpr auto equal_range(ForwardIt first, ForwardIt last, T const &value, Compare comp) -> pair< ForwardIt, ForwardIt >
Returns a range containing all elements equivalent to value in the range [first, last).
Definition equal_range.hpp:20
constexpr auto find_if(InputIt first, InputIt last, Predicate pred) noexcept -> InputIt
Searches for an element for which predicate p returns true.
Definition find_if.hpp:18
constexpr auto lower_bound(ForwardIt first, ForwardIt last, T const &value, Compare comp) noexcept -> ForwardIt
Returns an iterator pointing to the first element in the range [first, last) that is not less than (i...
Definition lower_bound.hpp:21
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 rotate(ForwardIt first, ForwardIt nFirst, ForwardIt last) -> ForwardIt
Performs a left rotation on a range of elements.
Definition rotate.hpp:17
constexpr auto lexicographical_compare(InputIt1 f1, InputIt1 l1, InputIt2 f2, InputIt2 l2, Compare comp) -> bool
Checks if the first range [f1, l1) is lexicographically less than the second range [f2,...
Definition lexicographical_compare.hpp:17
constexpr auto equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, Predicate p) -> bool
Returns true if the range [first1, last1) is equal to the range [first2, first2 + (last1 - first1)),...
Definition equal.hpp:18
constexpr auto upper_bound(ForwardIt first, ForwardIt last, T const &value, Compare comp) -> ForwardIt
Returns an iterator pointing to the first element in the range [first, last) that is greater than val...
Definition upper_bound.hpp:24
constexpr auto find(InputIt first, InputIt last, T const &value) noexcept -> InputIt
Searches for an element equal to value.
Definition find.hpp:18
constexpr auto end(C &c) -> decltype(c.end())
Returns an iterator to the end (i.e. the element after the last element) of the given container c or ...
Definition end.hpp:14
constexpr auto begin(C &c) -> decltype(c.begin())
Returns an iterator to the beginning of the given container c or array array. These templates rely on...
Definition begin.hpp:20
Definition adjacent_find.hpp:8
constexpr bool is_copy_constructible_v
Definition is_copy_constructible.hpp:30
constexpr auto operator==(inplace_function< R(Args...), Capacity, Alignment > const &f, nullptr_t) noexcept -> bool
Compares a etl::inplace_function with a null pointer. Empty functions (that is, functions without a c...
Definition inplace_function.hpp:262
pair(T1, T2) -> pair< T1, T2 >
auto declval() noexcept -> add_rvalue_reference_t< T >
constexpr auto operator!=(inplace_function< R(Args...), Capacity, Alignment > const &f, nullptr_t) noexcept -> bool
Compares a etl::inplace_function with a null pointer. Empty functions (that is, functions without a c...
Definition inplace_function.hpp:272
constexpr bool is_move_constructible_v
Definition is_move_constructible.hpp:20
constexpr bool is_default_constructible_v
Definition is_default_constructible.hpp:26
constexpr bool is_assignable_v
Definition is_assignable.hpp:20
constexpr auto operator<(etl::reverse_iterator< Iter1 > const &lhs, etl::reverse_iterator< Iter2 > const &rhs) -> bool
Compares the underlying iterators. Inverse comparisons are applied in order to take into account that...
Definition reverse_iterator.hpp:167
constexpr auto make_pair(T1 &&t, T2 &&u) -> pair< decay_t< T1 >, decay_t< T2 > >
Creates a etl::pair object, deducing the target type from the types of arguments.
Definition pair.hpp:164
TETL_BUILTIN_PTRDIFF ptrdiff_t
etl::ptrdiff_t is the signed integer type of the result of subtracting two pointers.
Definition ptrdiff_t.hpp:14
constexpr auto operator<=(etl::reverse_iterator< Iter1 > const &lhs, etl::reverse_iterator< Iter2 > const &rhs) -> bool
Compares the underlying iterators. Inverse comparisons are applied in order to take into account that...
Definition reverse_iterator.hpp:177
auto swap(inplace_function< R(Args...), Capacity, Alignment > &lhs, inplace_function< R(Args...), Capacity, Alignment > &rhs) noexcept -> void
Overloads the etl::swap algorithm for etl::inplace_function. Exchanges the state of lhs with that of ...
Definition inplace_function.hpp:249
constexpr auto operator>(etl::reverse_iterator< Iter1 > const &lhs, etl::reverse_iterator< Iter2 > const &rhs) -> bool
Compares the underlying iterators. Inverse comparisons are applied in order to take into account that...
Definition reverse_iterator.hpp:185
constexpr auto operator>=(etl::reverse_iterator< Iter1 > const &lhs, etl::reverse_iterator< Iter2 > const &rhs) -> bool
Compares the underlying iterators. Inverse comparisons are applied in order to take into account that...
Definition reverse_iterator.hpp:195
constexpr auto forward(remove_reference_t< T > ¶m) noexcept -> T &&
Forwards lvalues as either lvalues or as rvalues, depending on T. When t is a forwarding reference (a...
Definition forward.hpp:18
TETL_BUILTIN_SIZET size_t
etl::size_t is the unsigned integer type of the result of the sizeof operator.
Definition size_t.hpp:14
constexpr bool is_nothrow_swappable_v
Definition is_nothrow_swappable.hpp:19
etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit...
Definition pair.hpp:36
reverse_iterator is an iterator adaptor that reverses the direction of a given iterator....
Definition reverse_iterator.hpp:22
static_set is an associative container that contains a sorted set of unique objects of type Key....
Definition static_set.hpp:29
constexpr auto equal_range(key_type const &key) -> iterator
Returns a range containing all elements with the given key in the container. The range is defined by ...
Definition static_set.hpp:397
constexpr auto equal_range(K const &key) -> iterator
Returns a range containing all elements with the given key in the container. The range is defined by ...
Definition static_set.hpp:419
constexpr auto lower_bound(K const &key) const -> const_iterator
Returns an iterator pointing to the first element that is not less than (i.e. greater or equal to) ke...
Definition static_set.hpp:355
Compare value_compare
Definition static_set.hpp:48
constexpr auto find(key_type const &key) const noexcept -> const_iterator
Finds an element with key equivalent to key.
Definition static_set.hpp:286
typename storage_type::pointer iterator
Definition static_set.hpp:53
constexpr auto contains(key_type const &key) const noexcept -> bool
Checks if there is an element with key equivalent to key in the container.
Definition static_set.hpp:317
constexpr auto emplace(Args &&... args) noexcept(noexcept(insert(declval< key_type >()))) -> pair< iterator, bool >
Inserts a new element into the container constructed in-place with the given args if there is no elem...
Definition static_set.hpp:207
constexpr static_set(static_set &&other) noexcept(noexcept(etl::move(declval< storage_type >())))=default
constexpr auto erase(key_type const &key) noexcept -> size_type
Removes the element (if one exists) with the key equivalent to key.
Definition static_set.hpp:240
typename storage_type::value_type value_type
Definition static_set.hpp:44
constexpr auto value_comp() const noexcept -> value_compare
Returns the function object that compares the values. It is the same as key_comp.
Definition static_set.hpp:447
constexpr auto find(key_type const &key) noexcept -> iterator
Finds an element with key equivalent to key.
Definition static_set.hpp:277
Compare key_compare
Definition static_set.hpp:47
constexpr auto swap(static_set &other) noexcept(is_nothrow_swappable_v< key_type >) -> void requires(is_assignable_v< key_type &, key_type && >)
Exchanges the contents of the container with those of other.
Definition static_set.hpp:250
constexpr auto count(key_type const &key) const noexcept -> size_type
Returns the number of elements with key that compares equivalent to the specified argument,...
Definition static_set.hpp:259
constexpr auto crbegin() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the first element of the reversed set. It corresponds to the last eleme...
Definition static_set.hpp:123
etl::reverse_iterator< const_iterator > const_reverse_iterator
Definition static_set.hpp:56
value_type const & const_reference
Definition static_set.hpp:50
constexpr auto upper_bound(key_type const &key) -> iterator
Returns an iterator pointing to the first element that is greater than key.
Definition static_set.hpp:362
constexpr auto upper_bound(K const &key) -> iterator
Returns an iterator pointing to the first element that is greater than key.
Definition static_set.hpp:378
constexpr auto rbegin() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the first element of the reversed set. It corresponds to the last eleme...
Definition static_set.hpp:116
constexpr auto lower_bound(key_type const &key) -> iterator
Returns an iterator pointing to the first element that is not less than (i.e. greater or equal to) ke...
Definition static_set.hpp:330
constexpr auto find(K const &x) -> iterator
Finds an element with key that compares equivalent to the value x.
Definition static_set.hpp:295
typename storage_type::value_type key_type
Definition static_set.hpp:43
constexpr static_set()=default
Constructs empty container.
constexpr static_set(InputIt first, InputIt last)
Constructs with the contents of the range [first, last). If multiple elements in the range have keys ...
Definition static_set.hpp:66
constexpr auto lower_bound(key_type const &key) const -> const_iterator
Returns an iterator pointing to the first element that is not less than (i.e. greater or equal to) ke...
Definition static_set.hpp:337
constexpr auto rend() noexcept -> reverse_iterator
Returns a reverse iterator to the element following the last element of the reversed set....
Definition static_set.hpp:128
value_type & reference
Definition static_set.hpp:49
typename storage_type::pointer pointer
Definition static_set.hpp:51
constexpr auto begin() noexcept -> iterator
Returns an iterator to the first element of the set.
Definition static_set.hpp:90
constexpr auto insert(InputIter first, InputIter last) noexcept(noexcept(insert(declval< key_type >()))) -> void
Inserts elements from range [first, last). If multiple elements in the range have keys that compare e...
Definition static_set.hpp:195
constexpr auto end() noexcept -> iterator
Returns an iterator to the element following the last element of the set.
Definition static_set.hpp:100
constexpr auto begin() const noexcept -> const_iterator
Returns an iterator to the first element of the set.
Definition static_set.hpp:93
constexpr auto cbegin() const noexcept -> const_iterator
Returns an iterator to the first element of the set.
Definition static_set.hpp:96
size_t size_type
Definition static_set.hpp:45
constexpr auto insert(value_type const &value) noexcept(noexcept(insert(etl::move(declval< key_type >())))) -> pair< iterator, bool > requires(is_copy_constructible_v< value_type >)
Inserts element into the container, if the container doesn't already contain an element with an equiv...
Definition static_set.hpp:182
constexpr auto empty() const noexcept -> bool
Checks if the container has no elements, i.e. whether begin() == end().
Definition static_set.hpp:145
constexpr auto clear() noexcept -> void
Erases all elements from the container. After this call, size() returns zero.
Definition static_set.hpp:160
constexpr auto find(K const &x) const -> const_iterator
Finds an element with key that compares equivalent to the value x.
Definition static_set.hpp:307
etl::reverse_iterator< iterator > reverse_iterator
Definition static_set.hpp:55
constexpr auto equal_range(K const &key) const -> const_iterator
Returns a range containing all elements with the given key in the container. The range is defined by ...
Definition static_set.hpp:431
typename storage_type::const_pointer const_pointer
Definition static_set.hpp:52
constexpr auto count(K const &x) const -> size_type
Returns the number of elements with key that compares equivalent to the value x.
Definition static_set.hpp:268
typename storage_type::const_pointer const_iterator
Definition static_set.hpp:54
constexpr auto full() const noexcept -> bool
Checks if the container full, i.e. whether size() == Capacity.
Definition static_set.hpp:148
constexpr auto contains(K const &x) const -> bool
Checks if there is an element with key that compares equivalent to the value x.
Definition static_set.hpp:323
constexpr auto max_size() const noexcept -> size_type
Returns the maximum number of elements the container is able to hold.
Definition static_set.hpp:156
constexpr auto end() const noexcept -> const_iterator
Returns an iterator to the element following the last element of the set.
Definition static_set.hpp:104
constexpr auto upper_bound(K const &key) const -> const_iterator
Returns an iterator pointing to the first element that is greater than key.
Definition static_set.hpp:387
constexpr auto equal_range(key_type const &key) const -> const_iterator
Returns a range containing all elements with the given key in the container. The range is defined by ...
Definition static_set.hpp:407
constexpr auto operator=(static_set &&other) noexcept(noexcept(etl::move(declval< storage_type >()))) -> static_set &=default
constexpr static_set(static_set const &other)=default
constexpr auto lower_bound(K const &key) -> iterator
Returns an iterator pointing to the first element that is not less than (i.e. greater or equal to) ke...
Definition static_set.hpp:346
constexpr auto crend() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the element following the last element of the reversed set....
Definition static_set.hpp:141
constexpr auto insert(value_type &&value) -> pair< iterator, bool > requires(is_move_constructible_v< value_type >)
Inserts element into the container, if the container doesn't already contain an element with an equiv...
Definition static_set.hpp:164
constexpr auto erase(iterator pos) noexcept -> iterator
Removes the element at pos.
Definition static_set.hpp:217
constexpr auto erase(iterator first, iterator last) -> iterator
Removes the elements in the range [first; last), which must be a valid range in *this.
Definition static_set.hpp:225
constexpr auto upper_bound(key_type const &key) const -> const_iterator
Returns an iterator pointing to the first element that is greater than key.
Definition static_set.hpp:369
constexpr auto rend() const noexcept -> const_reverse_iterator
Returns a reverse iterator to the element following the last element of the reversed set....
Definition static_set.hpp:133
ptrdiff_t difference_type
Definition static_set.hpp:46
constexpr auto size() const noexcept -> size_type
Returns the number of elements in the container, i.e. distance(begin(), end()).
Definition static_set.hpp:152
constexpr auto cend() const noexcept -> const_iterator
Returns an iterator to the element following the last element of the set.
Definition static_set.hpp:108
constexpr auto operator=(static_set const &other) -> static_set &=default
constexpr auto key_comp() const noexcept -> key_compare
Returns the function object that compares the keys, which is a copy of this container's constructor a...
Definition static_set.hpp:441
constexpr auto rbegin() noexcept -> reverse_iterator
Returns a reverse iterator to the first element of the reversed set. It corresponds to the last eleme...
Definition static_set.hpp:112
Dynamically-resizable fixed-capacity vector.
Definition static_vector.hpp:329
typename base_type::pointer pointer
Definition static_vector.hpp:349
typename base_type::const_pointer const_pointer
Definition static_vector.hpp:351
typename base_type::value_type value_type
Definition static_vector.hpp:341