MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Memory::FlatMap< K, V, Compare > Class Template Reference

Map kept as one sorted vector, cheap to copy. More...

#include <FlatMap.hpp>

Inheritance diagram for MayaFlux::Memory::FlatMap< K, V, Compare >:
Collaboration diagram for MayaFlux::Memory::FlatMap< K, V, Compare >:

Public Types

using const_iterator = typename std::vector<value_type>::const_iterator
using value_type = std::pair<K, V>

Public Member Functions

const_iterator begin () const noexcept
void clear () noexcept
bool empty () const noexcept
const_iterator end () const noexcept
bool erase (const K &key)
 Removes the entry for key.
template<typename Q>
requires (!std::same_as<Q, K> && requires { typename Compare::is_transparent; })
bool erase (const Q &key)
 Removes the entry for a key of another type, as find does for lookup.
const_iterator find (const K &key) const
 The entry for key, or end() when absent.
template<typename Q>
requires (!std::same_as<Q, K> && requires { typename Compare::is_transparent; })
const_iterator find (const Q &key) const
 The entry for a key of another type, or end() when absent.
bool insert_or_assign (const K &key, V value)
 Sets the value for key, adding the entry if it is absent.
bool merge_prefixed (const FlatMap &other, std::string_view prefix, std::string &error, bool replace=false)
 Adds every entry of other under a name prefix.
size_t size () const noexcept

Private Member Functions

template<typename Q = K>
size_t lower_index (const Q &key) const

Private Attributes

std::vector< value_type > m_items
Compare m_less {}

Detailed Description

template<typename K, typename V, typename Compare = std::less<K>>
class MayaFlux::Memory::FlatMap< K, V, Compare >

Map kept as one sorted vector, cheap to copy.

Meant as the value of a SnapshotCell, which copies the whole value on every update. Lookup is a binary search, and insert and erase shift the tail, so it suits maps of up to a few thousand entries that are read far more often than they change.

Iteration is in key order. Insert and erase invalidate iterators.

Template Parameters
KKey type.
VMapped type.
CompareStrict weak ordering on K.

Definition at line 21 of file FlatMap.hpp.


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