Engine → Core → flat_map.h
flat_map
| Type | Class |
| Namespace | conjure::core |
| Include File Path | engine/include/conjure/core/containers/flat_map.h |
| Source File Path | N/A |
| API ↗ | Containers |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | flat_map() = default; | |
| public | explicit flat_map(
Compare compare); | |
| public | flat_map(
std::initializer_list<value_type> values); | Builds the map from pairs; for duplicate keys the first one wins. |
| public | flat_map(
const flat_map &) = default; | |
| public | flat_map(
flat_map &&) noexcept = default; |
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~flat_map() = default; |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mCompare | Compare | {} | |
| private | mEntries | storage_type | {} |
Functions
Public
at
at[[nodiscard]] V &at(
const K &key);The value for key. The key must be present: a missing key is a fatal programmer error (asserts, then terminates), never an exception.
[[nodiscard]] const V &at(
const K &key) const;template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] V &at(
const KeyLike &key);template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] const V &at(
const KeyLike &key) const;capacity
capacity[[nodiscard]] usize capacity() const noexcept;cbegin
cbegin[[nodiscard]] const_iterator cbegin() const noexcept;cend
cend[[nodiscard]] const_iterator cend() const noexcept;clear
clearvoid clear() noexcept;contains
contains[[nodiscard]] bool contains(
const K &key) const;template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] bool contains(
const KeyLike &key) const;count
count[[nodiscard]] usize count(
const K &key) const;0 or 1.
template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] usize count(
const KeyLike &key) const;emplace
emplacetemplate <typename... Args> std::pair<iterator, bool> emplace(
Args &&...args);Constructs a pair from the arguments and inserts it when its key is absent.
empty
empty[[nodiscard]] bool empty() const noexcept;entries
entries[[nodiscard]] std::span<const value_type> entries() const noexcept;The sorted pairs as a contiguous read-only view.
erase
erasebool erase(
const K &key);Removes the element with key. Returns false when absent.
template <typename KeyLike> requires detail::transparent_compare<Compare> && (!std::is_convertible_v<const KeyLike &, const_iterator>) && (!std::is_convertible_v<const KeyLike &, iterator>) bool erase(
const KeyLike &key);Removes the element whose key compares equal to key (transparent comparators only). Returns false when absent. Iterators are excluded so that they reach erase(position).
iterator erase(
const_iterator position);Removes the element at position. Returns the iterator following it.
iterator erase(
const_iterator first,
const_iterator last);find
find[[nodiscard]] iterator find(
const K &key);The element with key key, or end().
[[nodiscard]] const_iterator find(
const K &key) const;template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] iterator find(
const KeyLike &key);Heterogeneous lookup, available when Compare declares is_transparent (e.g. finding by std::string_view in a std::string keyed map).
template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] const_iterator find(
const KeyLike &key) const;insert
insertstd::pair<iterator, bool> insert(
const value_type &value);Inserts when the key is absent. Returns the element and whether it was inserted.
std::pair<iterator, bool> insert(
value_type &&value);template <std::input_iterator Iterator> void insert(
Iterator first,
Iterator last);Inserts every element of the range that is not already present.
insert_or_assign
insert_or_assigntemplate <typename M> std::pair<iterator, bool> insert_or_assign(
const K &key,
M &&value);Inserts or overwrites. Returns the element and true when it was newly inserted.
template <typename M> std::pair<iterator, bool> insert_or_assign(
K &&key,
M &&value);key_comp
key_comp[[nodiscard]] key_compare key_comp() const;lower_bound
lower_bound[[nodiscard]] iterator lower_bound(
const K &key);First element whose key is not less than key.
[[nodiscard]] const_iterator lower_bound(
const K &key) const;template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] iterator lower_bound(
const KeyLike &key);template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] const_iterator lower_bound(
const KeyLike &key) const;rbegin
rbegin[[nodiscard]] reverse_iterator rbegin() noexcept;[[nodiscard]] const_reverse_iterator rbegin() const noexcept;rend
rend[[nodiscard]] reverse_iterator rend() noexcept;[[nodiscard]] const_reverse_iterator rend() const noexcept;reserve
reservevoid reserve(
usize count);shrink_to_fit
shrink_to_fitvoid shrink_to_fit();size
size[[nodiscard]] usize size() const noexcept;swap
swapvoid swap(
flat_map &other) noexcept;try_emplace
try_emplacetemplate <typename... Args> std::pair<iterator, bool> try_emplace(
const K &key,
Args &&...args);Inserts {key, V(args...)} when key is absent; the value is only constructed in that case. Returns the element and whether it was inserted.
template <typename... Args> std::pair<iterator, bool> try_emplace(
K &&key,
Args &&...args);upper_bound
upper_bound[[nodiscard]] iterator upper_bound(
const K &key);First element whose key is greater than key.
[[nodiscard]] const_iterator upper_bound(
const K &key) const;template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] iterator upper_bound(
const KeyLike &key);template <typename KeyLike> requires detail::transparent_compare<Compare> [[nodiscard]] const_iterator upper_bound(
const KeyLike &key) const;Private
find_in
find_intemplate <typename Storage, typename KeyLike> [[nodiscard]] auto find_in(
Storage &storage,
const KeyLike &key) const;lower_bound_in
lower_bound_intemplate <typename Storage, typename KeyLike> [[nodiscard]] auto lower_bound_in(
Storage &storage,
const KeyLike &key) const;upper_bound_in
upper_bound_intemplate <typename Storage, typename KeyLike> [[nodiscard]] auto upper_bound_in(
Storage &storage,
const KeyLike &key) const;Operator Overloads
Public
operator=
operator=operator==
operator==[[nodiscard]] bool operator==(
const flat_map &other) const;operator[]
operator[][[nodiscard]] V &operator[](
const K &key);The value for key, default-constructed and inserted when absent.
[[nodiscard]] V &operator[](
K &&key);