An immutable-by-convention set of labels, kept sorted by name with duplicates collapsed last-wins.
More...
#include <labels.hpp>
|
| | Labels ()=default |
| |
| | Labels (const std::initializer_list< Label > init) |
| |
| | Labels (std::vector< Label > labels) |
| |
| void | set (std::string name, std::string value) |
| | Insert or overwrite a label (last write wins on a repeated name).
|
| |
| std::span< const Label > | view () const noexcept |
| | Read-only view over the sorted/deduped pairs.
|
| |
| bool | empty () const noexcept |
| |
| std::size_t | size () const noexcept |
| |
| std::size_t | hash () const noexcept |
| | 64-bit FNV-1a hash over the name\0value\0 stream; computed lazily and cached.
|
| |
| Labels | merged_with (const Labels &other) const |
| | Return *this overlaid with other; on a name collision other wins.
|
| |
| bool | operator== (const Labels &rhs) const |
| |
An immutable-by-convention set of labels, kept sorted by name with duplicates collapsed last-wins.
The 64-bit FNV-1a hash() is computed once and cached, which makes Labels cheap to use as a key for labeled-child caches (see the std::hash<Labels> specialization below).
◆ Labels() [1/3]
◆ Labels() [2/3]
| prom::Labels::Labels |
( |
const std::initializer_list< Label > |
init | ) |
|
|
inline |
◆ Labels() [3/3]
| prom::Labels::Labels |
( |
std::vector< Label > |
labels | ) |
|
|
inlineexplicit |
◆ empty()
| bool prom::Labels::empty |
( |
| ) |
const |
|
inlinenoexcept |
◆ hash()
| std::size_t prom::Labels::hash |
( |
| ) |
const |
|
inlinenoexcept |
64-bit FNV-1a hash over the name\0value\0 stream; computed lazily and cached.
Order-independent in effect because the set is always sorted.
◆ merged_with()
| Labels prom::Labels::merged_with |
( |
const Labels & |
other | ) |
const |
|
inline |
Return *this overlaid with other; on a name collision other wins.
◆ operator==()
| bool prom::Labels::operator== |
( |
const Labels & |
rhs | ) |
const |
|
inline |
◆ set()
| void prom::Labels::set |
( |
std::string |
name, |
|
|
std::string |
value |
|
) |
| |
|
inline |
Insert or overwrite a label (last write wins on a repeated name).
◆ size()
| std::size_t prom::Labels::size |
( |
| ) |
const |
|
inlinenoexcept |
◆ view()
| std::span< const Label > prom::Labels::view |
( |
| ) |
const |
|
inlinenoexcept |
Read-only view over the sorted/deduped pairs.
The documentation for this class was generated from the following file: