Skip to content

Engine → Core → flat_hash_map.h

flat_hash_set

Syntax

template <typename K, typename Hash = std::hash<K>, typename Eq = std::equal_to<K>> class flat_hash_set

Constructors

AccessSignatureDescription
publicflat_hash_set() = default;
publicexplicit flat_hash_set( usize initialCapacity);Pre-sizes the table for initialCapacity elements; 0 allocates nothing.
publicflat_hash_set( std::initializer_list<K> values);
publicflat_hash_set( const flat_hash_set &) = default;
publicflat_hash_set( flat_hash_set &&) noexcept = default;

Destructors

AccessSignatureDescription
public~flat_hash_set() = default;

Variables

AccessNameTypeDefaultDescription
publicMAX_CAPACITYstatic constexpr usizetable_type::MAX_CAPACITY
publicMAX_LOAD_FACTORstatic constexpr f32table_type::MAX_LOAD_FACTOR
privatemTabletable_type{}

Functions

Public

begin

[[nodiscard]] const_iterator begin() const noexcept;

capacity

[[nodiscard]] usize capacity() const noexcept;

cbegin

[[nodiscard]] const_iterator cbegin() const noexcept;

cend

[[nodiscard]] const_iterator cend() const noexcept;

clear

void clear() noexcept;

contains

[[nodiscard]] bool contains(
    const K &key) const noexcept;

count

[[nodiscard]] usize count(
    const K &key) const noexcept;

emplace

template <typename... Args> std::pair<const_iterator, bool> emplace(
    Args &&...args);

empty

[[nodiscard]] bool empty() const noexcept;

end

[[nodiscard]] const_iterator end() const noexcept;

erase

bool erase(
    const K &key) noexcept;
const_iterator erase(
    const_iterator position) noexcept;

find

[[nodiscard]] const_iterator find(
    const K &key) const noexcept;

insert

std::pair<const_iterator, bool> insert(
    const K &value);

Inserts when absent. Returns the element and whether it was inserted.

std::pair<const_iterator, bool> insert(
    K &&value);
template <std::input_iterator Iterator> void insert(
    Iterator first,
    Iterator last);

load_factor

[[nodiscard]] f32 load_factor() const noexcept;

reserve

void reserve(
    usize count);

Makes room for count elements without a rehash during the next insertions. reserve(0) does nothing, so an empty set stays unallocated.

size

[[nodiscard]] usize size() const noexcept;

swap

void swap(
    flat_hash_set &other) noexcept;

Operator Overloads

Public

operator=

flat_hash_set &operator=(
    const flat_hash_set &) = default;
flat_hash_set &operator=(
    flat_hash_set &&) noexcept = default;

operator==

[[nodiscard]] bool operator==(
    const flat_hash_set &other) const;

Same elements, regardless of slot order.