|
|
| interned_key_list () noexcept |
| | Construct a list holding no key and no entry.
|
|
| interned_key_list (const interned_key_list &other) |
|
| interned_key_list (interned_key_list &&other) noexcept |
|
interned_key_list & | operator= (const interned_key_list &other) |
|
interned_key_list & | operator= (interned_key_list &&other) noexcept |
| std::size_t | intern (std::string key) |
| | Intern a key without appending an entry.
|
| std::size_t | append (std::size_t key_index) |
| | Append one entry referring to an interned key.
|
| std::size_t | append (std::string key) |
| | Intern a key and append one entry referring to it.
|
|
void | clear () noexcept |
| | Drop every key and every entry, keeping both capacities.
|
| void | reserve (std::size_t keys, std::size_t entries) |
| | Make room without allocating later.
|
| std::size_t | find (const std::string &key) const noexcept |
| | Get the index a key was interned under.
|
| std::size_t | get_entry_count () const noexcept |
| | Get how many entries are held.
|
| const std::string & | get (std::size_t entry_index) const noexcept |
| | Get the key one entry refers to.
|
| std::size_t | get_key_index (std::size_t entry_index) const noexcept |
| | Get which interned key one entry refers to.
|
| std::size_t | get_key_count () const noexcept |
| | Get how many distinct keys are held.
|
| const std::string & | get_key (std::size_t key_index) const noexcept |
| | Get one of the interned keys.
|
A list of keys in which equal keys are held once.
Each entry of the list refers to a key, and entries naming the same key share one copy of it: the distinct keys are held once and the entries are indices into them. A list naming a few keys many times over therefore costs a string per distinct key rather than per entry.
The list has two sizes. get_key_count is how many distinct keys were interned and get_entry_count how many entries there are. Each is addressed on its own: get_key takes a key index, get an entry index.
clear keeps both capacities, so a list refilled after clearing allocates only the strings of the keys it interns.
| std::size_t vitrio::interned_key_list::intern |
( |
std::string | key | ) |
|
Intern a key without appending an entry.
A key equal to one already interned yields the index it was given the first time rather than a second one, so a key can be interned once and referred to by index afterwards.
The interned keys are searched one by one, so this takes time in proportion to the number of distinct keys, not of entries.
- Parameters
-
- Returns
- std::size_t Index of the key, below get_key_count.