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

◆ const_reverse_iterator

◆ container_type

◆ 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

◆ key_type

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

◆ reference

◆ reverse_iterator

◆ size_type

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

◆ value_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>>
constexpr flat_set ( )
inlineconstexpr

◆ flat_set() [2/6]

template<typename Key , typename Container , typename Compare = etl::less<Key>>
constexpr 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>>
constexpr flat_set ( etl::sorted_unique_t  ,
container_type  cont 
)
inlineconstexpr

◆ flat_set() [4/6]

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

◆ flat_set() [5/6]

template<typename Key , typename Container , typename Compare = etl::less<Key>>
template<typename InputIt >
constexpr 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 >
constexpr 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>>
constexpr auto begin ( ) const -> const_iterator
inlineconstexprnoexcept

◆ begin() [2/2]

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

◆ cbegin()

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

◆ cend()

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

◆ clear()

template<typename Key , typename Container , typename Compare = etl::less<Key>>
constexpr 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>
constexpr auto contains ( K const key) const -> bool
inlineconstexpr

◆ contains() [2/2]

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

◆ count() [1/2]

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

◆ count() [2/2]

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

◆ crbegin()

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

◆ crend()

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

◆ emplace()

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

◆ emplace_hint()

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

◆ empty()

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

Returns true if the underlying container is empty.

◆ end() [1/2]

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

◆ end() [2/2]

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

◆ equal_range() [1/4]

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

◆ equal_range() [2/4]

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

◆ equal_range() [3/4]

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

◆ equal_range() [4/4]

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

◆ erase() [1/4]

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

◆ erase() [2/4]

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

◆ erase() [3/4]

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

◆ erase() [4/4]

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

◆ extract()

template<typename Key , typename Container , typename Compare = etl::less<Key>>
constexpr 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>
constexpr auto find ( K const key) -> iterator
inlineconstexpr

◆ find() [2/4]

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

◆ find() [3/4]

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

◆ find() [4/4]

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

◆ insert() [1/6]

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

◆ insert() [2/6]

template<typename Key , typename Container , typename Compare = etl::less<Key>>
constexpr 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 >
constexpr 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 >
constexpr auto insert ( InputIt  first,
InputIt  last 
) -> void
inlineconstexpr

◆ insert() [5/6]

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

◆ insert() [6/6]

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

◆ key_comp()

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

◆ lower_bound() [1/4]

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

◆ lower_bound() [2/4]

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

◆ lower_bound() [3/4]

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

◆ lower_bound() [4/4]

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

◆ max_size()

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

Returns the max_size of the underlying container.

◆ rbegin() [1/2]

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

◆ rbegin() [2/2]

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

◆ rend() [1/2]

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

◆ rend() [2/2]

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

◆ replace()

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

◆ size()

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

Returns the size of the underlying container.

◆ swap()

template<typename Key , typename Container , typename Compare = etl::less<Key>>
constexpr 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>
constexpr auto upper_bound ( K const key) -> iterator
inlineconstexpr

◆ upper_bound() [2/4]

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

◆ upper_bound() [3/4]

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

◆ upper_bound() [4/4]

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

◆ value_comp()

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

Friends And Related Symbol Documentation

◆ operator<

template<typename Key , typename Container , typename Compare = etl::less<Key>>
constexpr 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>>
constexpr 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>>
constexpr 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>>
constexpr 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>>
constexpr 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>>
constexpr 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: