mdds
|
#include <trie_map.hpp>
Classes | |
class | const_node_type |
Public Types | |
using | traits_type = TraitsT |
typedef packed_trie_map< KeyT, ValueT, TraitsT > | packed_type |
typedef KeyT | key_type |
typedef key_type::value_type | key_unit_type |
typedef ValueT | value_type |
typedef size_t | size_type |
using | const_iterator = trie::detail::const_iterator< trie_map > |
using | iterator = trie::detail::iterator< trie_map > |
typedef trie::detail::search_results< trie_map > | search_results |
Public Member Functions | |
trie_map () | |
trie_map (const trie_map &other) | |
trie_map (trie_map &&other) | |
const_iterator | begin () const |
iterator | begin () |
const_iterator | end () const |
iterator | end () |
trie_map & | operator= (trie_map other) |
bool | operator== (const trie_map &other) const |
bool | operator!= (const trie_map &other) const |
void | swap (trie_map &other) |
const_node_type | root_node () const |
void | insert (const key_type &key, value_type value) |
void | insert (const key_unit_type *key, size_type len, value_type value) |
bool | erase (const key_unit_type *key, size_type len) |
const_iterator | find (const key_type &key) const |
const_iterator | find (const key_unit_type *input, size_type len) const |
iterator | find (const key_type &key) |
iterator | find (const key_unit_type *input, size_type len) |
search_results | prefix_search (const key_type &prefix) const |
search_results | prefix_search (const key_unit_type *prefix, size_type len) const |
size_type | size () const |
bool | empty () const noexcept |
void | clear () |
packed_type | pack () |
Trie map provides storage for multiple key-value pairs where keys are either strings, or otherwise consist of arrays of characters. The keys are stored in an ordered tree structure known as trie, or sometimes referred to as prefix tree.
mdds::trie_map< KeyT, ValueT, TraitsT >::trie_map | ( | ) |
Default constructor.
void mdds::trie_map< KeyT, ValueT, TraitsT >::clear | ( | ) |
Empty the container.
bool mdds::trie_map< KeyT, ValueT, TraitsT >::erase | ( | const key_unit_type * | key, |
size_type | len | ||
) |
Erase a key and the value associated with it.
key | pointer to the first character of a character array that stores key value. |
len | length of the character array storing the key. |
iterator mdds::trie_map< KeyT, ValueT, TraitsT >::find | ( | const key_type & | key | ) |
Find a value associated with a specified key.
key | key to match. |
const_iterator mdds::trie_map< KeyT, ValueT, TraitsT >::find | ( | const key_type & | key | ) | const |
Find a value associated with a specified key.
key | key to match. |
iterator mdds::trie_map< KeyT, ValueT, TraitsT >::find | ( | const key_unit_type * | input, |
size_type | len | ||
) |
Find a value associated with a specified key.
input | pointer to an array whose value represents the key to match. |
len | length of the matching key value. |
const_iterator mdds::trie_map< KeyT, ValueT, TraitsT >::find | ( | const key_unit_type * | input, |
size_type | len | ||
) | const |
Find a value associated with a specified key.
input | pointer to an array whose value represents the key to match. |
len | length of the matching key value. |
void mdds::trie_map< KeyT, ValueT, TraitsT >::insert | ( | const key_type & | key, |
value_type | value | ||
) |
Insert a new key-value pair.
key | key value. |
value | value to associate with the key. |
void mdds::trie_map< KeyT, ValueT, TraitsT >::insert | ( | const key_unit_type * | key, |
size_type | len, | ||
value_type | value | ||
) |
Insert a new key-value pair.
key | pointer to the first character of a character array that stores key value. |
len | length of the character array storing the key. |
value | value to associate with the key. |
packed_type mdds::trie_map< KeyT, ValueT, TraitsT >::pack | ( | ) |
Create a compressed and immutable version of the container which provides better search performance and requires much less memory footprint.
mdds::size_error | When the number of entries exceeds maximum allowed number of key-value pairs. See trie::default_traits::pack_value_type for more detailed explanation. |
search_results mdds::trie_map< KeyT, ValueT, TraitsT >::prefix_search | ( | const key_type & | prefix | ) | const |
Retrieve all key-value pairs whose keys start with specified prefix. You can also retrieve all key-value pairs by passing a null prefix and a length of zero.
prefix | prefix to match. |
search_results mdds::trie_map< KeyT, ValueT, TraitsT >::prefix_search | ( | const key_unit_type * | prefix, |
size_type | len | ||
) | const |
Retrieve all key-value pairs whose keys start with specified prefix. You can also retrieve all key-value pairs by passing a null prefix and a length of zero.
prefix | pointer to an array whose value represents the prefix to match. |
len | length of the prefix value to match. |
const_node_type mdds::trie_map< KeyT, ValueT, TraitsT >::root_node | ( | ) | const |
Obtain a root node of the trie to traverse it node-by-node.
size_type mdds::trie_map< KeyT, ValueT, TraitsT >::size | ( | ) | const |
Return the number of entries in the map.