tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
flat_set< Key, Container, Compare > Struct Template Reference

A flat_set is a container adaptor that provides an associative container interface that supports unique keys (contains at most one of each key value) and provides for fast retrieval of the keys themselves. flat_set supports random access iterators. Any sequence container supporting random access iteration can be used to instantiate flat_set. More...

#include <etl/flat_set.hpp>

Public Types

using const_iterator = typename Container::const_iterator
 
using const_reference = value_type const&
 
using const_reverse_iterator = etl::reverse_iterator<const_iterator>
 
using container_type = Container
 
using difference_type = typename Container::difference_type
 
using iterator = typename Container::iterator
 
using key_compare = Compare
 
using key_type = Key
 
using reference = value_type&
 
using reverse_iterator = etl::reverse_iterator<iterator>
 
using size_type = typename Container::size_type
 
using value_compare = Compare
 
using value_type = Key
 

Public Member Functions

constexpr flat_set ()
 
constexpr flat_set (Compare const &comp)
 
constexpr flat_set (container_type const &container)
 Initializes c with etl::move(cont), value-initializes compare, sorts the range [begin(),end()) with respect to compare, and finally erases the range [ranges::unique(*this, compare), end());.
 
constexpr flat_set (etl::sorted_unique_t, container_type cont)
 
template<typename InputIt>
constexpr flat_set (etl::sorted_unique_t, InputIt first, InputIt last, Compare const &comp=Compare())
 
template<typename InputIt>
constexpr flat_set (InputIt first, InputIt last, Compare const &comp=Compare())
 
constexpr auto begin () const noexcept -> const_iterator
 
constexpr auto begin () noexcept -> iterator
 
constexpr auto cbegin () const noexcept -> const_iterator
 
constexpr auto cend () const noexcept -> const_iterator
 
constexpr auto clear () noexcept -> void
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto contains (K const &key) const -> bool
 
constexpr auto contains (key_type const &key) const -> bool
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto count (K const &key) const -> size_type
 
constexpr auto count (key_type const &key) const -> size_type
 
constexpr auto crbegin () const noexcept -> const_reverse_iterator
 
constexpr auto crend () const noexcept -> const_reverse_iterator
 
template<typename... Args>
constexpr auto emplace (Args &&... args) -> etl::pair< iterator, bool >
 
template<typename... Args>
constexpr auto emplace_hint (const_iterator, Args &&... args) -> iterator
 
constexpr auto empty () const noexcept -> bool
 Returns true if the underlying container is empty.
 
constexpr auto end () const noexcept -> const_iterator
 
constexpr auto end () noexcept -> iterator
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto equal_range (K const &key) -> etl::pair< iterator, iterator >
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto equal_range (K const &key) const -> etl::pair< const_iterator, const_iterator >
 
constexpr auto equal_range (key_type const &key) -> etl::pair< iterator, iterator >
 
constexpr auto equal_range (key_type const &key) const -> etl::pair< const_iterator, const_iterator >
 
constexpr auto erase (const_iterator first, const_iterator last) -> iterator
 
constexpr auto erase (const_iterator position) -> iterator
 
constexpr auto erase (iterator position) -> iterator
 
constexpr auto erase (key_type const &key) -> size_type
 
constexpr auto extract () &&-> container_type
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto find (K const &key) -> iterator
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto find (K const &key) const -> const_iterator
 
constexpr auto find (key_type const &key) -> iterator
 
constexpr auto find (key_type const &key) const -> const_iterator
 
constexpr auto insert (const_iterator position, value_type &&x) -> iterator
 
constexpr auto insert (const_iterator position, value_type const &x) -> iterator
 
template<typename InputIt>
constexpr auto insert (etl::sorted_unique_t, InputIt first, InputIt last) -> void
 
template<typename InputIt>
constexpr auto insert (InputIt first, InputIt last) -> void
 
constexpr auto insert (value_type &&x) -> etl::pair< iterator, bool >
 
constexpr auto insert (value_type const &x) -> etl::pair< iterator, bool >
 
constexpr auto key_comp () const -> key_compare
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto lower_bound (K const &key) -> iterator
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto lower_bound (K const &key) const -> const_iterator
 
constexpr auto lower_bound (key_type const &key) -> iterator
 
constexpr auto lower_bound (key_type const &key) const -> const_iterator
 
constexpr auto max_size () const noexcept -> size_type
 Returns the max_size of the underlying container.
 
constexpr auto rbegin () const noexcept -> const_reverse_iterator
 
constexpr auto rbegin () noexcept -> reverse_iterator
 
constexpr auto rend () const noexcept -> const_reverse_iterator
 
constexpr auto rend () noexcept -> reverse_iterator
 
constexpr auto replace (container_type &&container) -> void
 
constexpr auto size () const noexcept -> size_type
 Returns the size of the underlying container.
 
constexpr auto swap (flat_set &other) noexcept(etl::is_nothrow_swappable_v< Container > &&etl::is_nothrow_swappable_v< Compare >) -> void
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto upper_bound (K const &key) -> iterator
 
template<typename K>
requires etl::detail::is_transparent_v<Compare>
constexpr auto upper_bound (K const &key) const -> const_iterator
 
constexpr auto upper_bound (key_type const &key) -> iterator
 
constexpr auto upper_bound (key_type const &key) const -> const_iterator
 
constexpr auto value_comp () const -> value_compare
 

Friends

constexpr auto operator< (flat_set const &lhs, flat_set const &rhs) -> bool
 
constexpr auto operator<= (flat_set const &x, flat_set const &y) -> bool
 
constexpr auto operator== (flat_set const &lhs, flat_set const &rhs) -> bool
 
constexpr auto operator> (flat_set const &x, flat_set const &y) -> bool
 
constexpr auto operator>= (flat_set const &x, flat_set const &y) -> bool
 
constexpr auto swap (flat_set &x, flat_set &y) noexcept(noexcept(x.swap(y))) -> void
 

Detailed Description

template<typename Key, typename Container, typename Compare = etl::less<Key>>
struct etl::flat_set< Key, Container, Compare >

A flat_set is a container adaptor that provides an associative container interface that supports unique keys (contains at most one of each key value) and provides for fast retrieval of the keys themselves. flat_set supports random access iterators. Any sequence container supporting random access iteration can be used to instantiate flat_set.

A flat_set satisfies all of the requirements of a container and of a reversible container. flat_set satisfies the requirements of an associative container, except that:

  • it does not meet the requirements related to node handles,
  • it does not meet the requirements related to iterator invalidation, and
  • the time complexity of the insert, emplace, emplace_hint, and erase members that respectively insert, emplace or erase a single element from the set is linear, including the ones that take an insertion position iterator.
  • https://isocpp.org/files/papers/P1222R1.pdf
  • https://youtu.be/b9ZYM0d6htg

Member Typedef Documentation

◆ const_iterator

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using const_iterator = typename Container::const_iterator

◆ const_reference

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using const_reference = value_type const&

◆ const_reverse_iterator

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using const_reverse_iterator = etl::reverse_iterator<const_iterator>

◆ container_type

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using container_type = Container

◆ difference_type

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using difference_type = typename Container::difference_type

◆ iterator

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using iterator = typename Container::iterator

◆ key_compare

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using key_compare = Compare

◆ key_type

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using key_type = Key

◆ reference

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using reference = value_type&

◆ reverse_iterator

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using reverse_iterator = etl::reverse_iterator<iterator>

◆ size_type

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using size_type = typename Container::size_type

◆ value_compare

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using value_compare = Compare

◆ value_type

template<typename Key, typename Container, typename Compare = etl::less<Key>>
using value_type = Key

Constructor & Destructor Documentation

◆ flat_set() [1/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
flat_set ( )
inlineconstexpr

◆ flat_set() [2/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
flat_set ( container_type const & container)
inlineexplicitconstexpr

Initializes c with etl::move(cont), value-initializes compare, sorts the range [begin(),end()) with respect to compare, and finally erases the range [ranges::unique(*this, compare), end());.

Complexity: Linear in N if cont is sorted with respect to compare and otherwise N log N, where N is cont.size().

◆ flat_set() [3/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
flat_set ( etl::sorted_unique_t ,
container_type cont )
inlineconstexpr

◆ flat_set() [4/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
flat_set ( Compare const & comp)
inlineexplicitconstexpr

◆ flat_set() [5/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename InputIt>
flat_set ( InputIt first,
InputIt last,
Compare const & comp = Compare() )
inlineconstexpr

◆ flat_set() [6/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename InputIt>
flat_set ( etl::sorted_unique_t ,
InputIt first,
InputIt last,
Compare const & comp = Compare() )
inlineconstexpr

Member Function Documentation

◆ begin() [1/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto begin ( ) const -> const_iterator
inlinenodiscardconstexprnoexcept

◆ begin() [2/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto begin ( ) -> iterator
inlinenodiscardconstexprnoexcept

◆ cbegin()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto cbegin ( ) const -> const_iterator
inlinenodiscardconstexprnoexcept

◆ cend()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto cend ( ) const -> const_iterator
inlinenodiscardconstexprnoexcept

◆ clear()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto clear ( ) -> void
inlineconstexprnoexcept

◆ contains() [1/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto contains ( K const & key) const -> bool
inlinenodiscardconstexpr

◆ contains() [2/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto contains ( key_type const & key) const -> bool
inlinenodiscardconstexpr

◆ count() [1/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto count ( K const & key) const -> size_type
inlinenodiscardconstexpr

◆ count() [2/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto count ( key_type const & key) const -> size_type
inlinenodiscardconstexpr

◆ crbegin()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto crbegin ( ) const -> const_reverse_iterator
inlinenodiscardconstexprnoexcept

◆ crend()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto crend ( ) const -> const_reverse_iterator
inlinenodiscardconstexprnoexcept

◆ emplace()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename... Args>
auto emplace ( Args &&... args) -> etl::pair<iterator, bool>
inlineconstexpr

◆ emplace_hint()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename... Args>
auto emplace_hint ( const_iterator ,
Args &&... args ) -> iterator
inlineconstexpr

◆ empty()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto empty ( ) const -> bool
inlinenodiscardconstexprnoexcept

Returns true if the underlying container is empty.

◆ end() [1/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto end ( ) const -> const_iterator
inlinenodiscardconstexprnoexcept

◆ end() [2/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto end ( ) -> iterator
inlinenodiscardconstexprnoexcept

◆ equal_range() [1/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto equal_range ( K const & key) -> etl::pair<iterator, iterator>
inlinenodiscardconstexpr

◆ equal_range() [2/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto equal_range ( K const & key) const -> etl::pair<const_iterator, const_iterator>
inlinenodiscardconstexpr

◆ equal_range() [3/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto equal_range ( key_type const & key) -> etl::pair<iterator, iterator>
inlinenodiscardconstexpr

◆ equal_range() [4/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto equal_range ( key_type const & key) const -> etl::pair<const_iterator, const_iterator>
inlinenodiscardconstexpr

◆ erase() [1/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto erase ( const_iterator first,
const_iterator last ) -> iterator
inlineconstexpr

◆ erase() [2/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto erase ( const_iterator position) -> iterator
inlineconstexpr

◆ erase() [3/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto erase ( iterator position) -> iterator
inlineconstexpr

◆ erase() [4/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto erase ( key_type const & key) -> size_type
inlineconstexpr

◆ extract()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto extract ( ) && -> container_type
inlineconstexpr

◆ find() [1/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto find ( K const & key) -> iterator
inlinenodiscardconstexpr

◆ find() [2/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto find ( K const & key) const -> const_iterator
inlinenodiscardconstexpr

◆ find() [3/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto find ( key_type const & key) -> iterator
inlinenodiscardconstexpr

◆ find() [4/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto find ( key_type const & key) const -> const_iterator
inlinenodiscardconstexpr

◆ insert() [1/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto insert ( const_iterator position,
value_type && x ) -> iterator
inlineconstexpr

◆ insert() [2/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto insert ( const_iterator position,
value_type const & x ) -> iterator
inlineconstexpr

◆ insert() [3/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename InputIt>
auto insert ( etl::sorted_unique_t ,
InputIt first,
InputIt last ) -> void
constexpr

◆ insert() [4/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename InputIt>
auto insert ( InputIt first,
InputIt last ) -> void
inlineconstexpr

◆ insert() [5/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto insert ( value_type && x) -> etl::pair<iterator, bool>
inlineconstexpr

◆ insert() [6/6]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto insert ( value_type const & x) -> etl::pair<iterator, bool>
inlineconstexpr

◆ key_comp()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto key_comp ( ) const -> key_compare
inlinenodiscardconstexpr

◆ lower_bound() [1/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto lower_bound ( K const & key) -> iterator
inlinenodiscardconstexpr

◆ lower_bound() [2/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto lower_bound ( K const & key) const -> const_iterator
inlinenodiscardconstexpr

◆ lower_bound() [3/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto lower_bound ( key_type const & key) -> iterator
inlinenodiscardconstexpr

◆ lower_bound() [4/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto lower_bound ( key_type const & key) const -> const_iterator
inlinenodiscardconstexpr

◆ max_size()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto max_size ( ) const -> size_type
inlinenodiscardconstexprnoexcept

Returns the max_size of the underlying container.

◆ rbegin() [1/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto rbegin ( ) const -> const_reverse_iterator
inlinenodiscardconstexprnoexcept

◆ rbegin() [2/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto rbegin ( ) -> reverse_iterator
inlinenodiscardconstexprnoexcept

◆ rend() [1/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto rend ( ) const -> const_reverse_iterator
inlinenodiscardconstexprnoexcept

◆ rend() [2/2]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto rend ( ) -> reverse_iterator
inlinenodiscardconstexprnoexcept

◆ replace()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto replace ( container_type && container) -> void
inlineconstexpr

◆ size()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto size ( ) const -> size_type
inlinenodiscardconstexprnoexcept

Returns the size of the underlying container.

◆ swap()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto swap ( flat_set< Key, Container, Compare > & other) -> void
inlineconstexprnoexcept

◆ upper_bound() [1/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto upper_bound ( K const & key) -> iterator
inlinenodiscardconstexpr

◆ upper_bound() [2/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
template<typename K>
requires etl::detail::is_transparent_v<Compare>
auto upper_bound ( K const & key) const -> const_iterator
inlinenodiscardconstexpr

◆ upper_bound() [3/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto upper_bound ( key_type const & key) -> iterator
inlinenodiscardconstexpr

◆ upper_bound() [4/4]

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto upper_bound ( key_type const & key) const -> const_iterator
inlinenodiscardconstexpr

◆ value_comp()

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto value_comp ( ) const -> value_compare
inlinenodiscardconstexpr

Friends And Related Symbol Documentation

◆ operator<

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto operator< ( flat_set< Key, Container, Compare > const & lhs,
flat_set< Key, Container, Compare > const & rhs ) -> bool
friend

◆ operator<=

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto operator<= ( flat_set< Key, Container, Compare > const & x,
flat_set< Key, Container, Compare > const & y ) -> bool
friend

◆ operator==

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto operator== ( flat_set< Key, Container, Compare > const & lhs,
flat_set< Key, Container, Compare > const & rhs ) -> bool
friend

◆ operator>

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto operator> ( flat_set< Key, Container, Compare > const & x,
flat_set< Key, Container, Compare > const & y ) -> bool
friend

◆ operator>=

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto operator>= ( flat_set< Key, Container, Compare > const & x,
flat_set< Key, Container, Compare > const & y ) -> bool
friend

◆ swap

template<typename Key, typename Container, typename Compare = etl::less<Key>>
auto swap ( flat_set< Key, Container, Compare > & x,
flat_set< Key, Container, Compare > & y ) -> void
friend

The documentation for this struct was generated from the following file: