A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../algorithm/../container/flat_set.html below:

std::flat_set - cppreference.com

template<

    class Key,
    class Compare = std::less<Key>,
    class KeyContainer = std::vector<Key>

> class flat_set;
(since C++23)

The flat set is a container adaptor that gives the functionality of an associative container that stores a sorted set of unique objects of type Key. Sorting is done using the key comparison function Compare.

The class template flat_set acts as a wrapper to the underlying sorted container passed as object of type KeyContainer.

Everywhere the standard library uses the Compare requirements, uniqueness is determined by using the equivalence relation. Informally, two objects a and b are considered equivalent if neither compares less than the other: !comp(a, b) && !comp(b, a).

std::flat_set meets the requirements of Container, ReversibleContainer, optional container requirements, and all requirements of AssociativeContainer (including logarithmic search complexity), except that:

A flat set supports most AssociativeContainer's operations that use unique keys.

All member functions of std::flat_set are constexpr: it is possible to create and use std::flat_set objects in the evaluation of a constant expression.

However, std::flat_set objects generally cannot be constexpr, because any dynamically allocated storage must be released in the same evaluation of constant expression.

(since C++26) [edit] Iterator invalidation [edit] Template parameters [edit] Member types [edit] Member objects Member Description container_type c (private) the adapted container
(exposition-only member object*) key_compare compare (private) the comparison function object
(exposition-only member object*) [edit] Member functions constructs the flat_set
(public member function) [edit]

(destructor)

(implicitly declared)

destroys every element of the container adaptor
(public member function) assigns values to the container adaptor
(public member function) [edit] Iterators returns an iterator to the beginning
(public member function) [edit] returns an iterator to the end
(public member function) [edit] returns a reverse iterator to the beginning
(public member function) [edit] returns a reverse iterator to the end
(public member function) [edit] Capacity checks whether the container adaptor is empty
(public member function) [edit] returns the number of elements
(public member function) [edit] returns the maximum possible number of elements
(public member function) [edit] Modifiers constructs element in-place
(public member function) [edit] constructs elements in-place using a hint
(public member function) [edit] inserts elements
(public member function) [edit] inserts a range of elements
(public member function) [edit] extracts the underlying container
(public member function) [edit] replaces the underlying container
(public member function) [edit] erases elements
(public member function) [edit] swaps the contents
(public member function) [edit] clears the contents
(public member function) [edit] Lookup finds element with specific key
(public member function) [edit] returns the number of elements matching specific key
(public member function) [edit] checks if the container contains element with specific key
(public member function) [edit] returns an iterator to the first element not less than the given key
(public member function) [edit] returns an iterator to the first element greater than the given key
(public member function) [edit] returns range of elements matching a specific key
(public member function) [edit] Observers returns the function that compares keys
(public member function) [edit] returns the function that compares keys in objects of type value_type
(public member function) [edit] [edit] Non-member functions [edit] Helper classes [edit] Tags [edit] Deduction guides [edit] Notes

The member types iterator and const_iterator may be aliases to the same type. This means defining a pair of function overloads using the two types as parameter types may violate the One Definition Rule. Since iterator is convertible to const_iterator, a single function with a const_iterator as parameter type will work instead.

Some advantages of flat set over other standard container adaptors are:

Some disadvantages of flat set are:

[edit] Example [edit] See also adapts a container to provide a collection of keys, sorted by keys
(class template) [edit] collection of unique keys, sorted by keys
(class template) [edit] collection of unique keys, hashed by keys
(class template) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4