cptr::detail::basic_ordered_map

The class behind cptr::ordered_map; use that alias. Its members behave like those of std::map; the alias lists the differences.

Synopsis

Declared in <cptr/ordered_map.hpp>

template<
    class K,
    class V,
    class Compare,
    class Cage,
    bool Compressed>
class basic_ordered_map;

Description

The map behind cptr::ordered_map. Compressed = false gives the same tree with raw 8-byte links, which the benchmarks compare against.

A red-black tree with parent links. A header node in the cage holds the root, the leftmost and the rightmost node, and serves as end(), so iterators are a single node pointer and the map object can live anywhere.

Types

Name
basic_iterator

Type Aliases

Name
const_iterator
const_reference
const_reverse_iterator
difference_type
iterator
key_compare
key_type
mapped_type
reference
reverse_iterator
size_type
value_type

Member Functions

NameDescription
basic_ordered_map [constructor]Constructors
~basic_ordered_map [destructor]Destructor
operator= Assignment operators
at
begin
cbegin
cend
clear
contains
count
crbegin
crend
emplace Build the element from args, then insert it unless its key is present; returns the element with that key and whether it was inserted. As for std::map, the element is built first, even when the key turns out to be present (try_emplace avoids that). If the comparison or an allocation throws, the element is destroyed and the map is unchanged.
emplace_hint As emplace(). The hint is accepted for compatibility with std::map and generic code such as std::inserter, but not used: the search always starts at the root.
empty
end
equal_range
erase Erases the element with the given key, if there is one; returns how many were erased (0 or 1).
find Lookup. The template overloads take any key type that a transparent comparator (one with is_transparent, such as std::less<>) accepts.
height The number of nodes on the longest path from the root; for tests.
insert insert overloads
insert_or_assign insert_or_assign overloads
key_comp
lower_bound
max_size
operator[] Subscript operators
rbegin
rend
size
swap
try_emplace try_emplace overloads
upper_bound
valid Checks the red-black and ordering invariants and the header; for tests.

Static Data Members

NameDescription
node_size Bytes per element, including the links: what the cage hands out.

Friends

NameDescription
cptr::detail::operator<=>Lexicographical over the (key, value) pairs, with std's synth-three-way: types that have only operator< give a std::weak_ordering.
cptr::detail::operator==Equality operator
cptr::detail::swap