mdds
|
#include <trie_map.hpp>
Public Types | |
typedef packed_trie_map< KeyTraits, ValueT > | packed_type |
typedef KeyTraits | key_traits_type |
typedef key_traits_type::key_type | key_type |
typedef key_traits_type::key_buffer_type | key_buffer_type |
typedef key_traits_type::key_unit_type | key_unit_type |
typedef ValueT | value_type |
typedef size_t | size_type |
typedef std::pair< key_type, value_type > | key_value_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) |
void | swap (trie_map &other) |
void | insert (const key_type &key, const value_type &value) |
void | insert (const key_unit_type *key, size_type len, const 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 () const |
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< KeyTraits, ValueT >::trie_map | ( | ) |
Default constructor.
void mdds::trie_map< KeyTraits, ValueT >::clear | ( | ) |
Empty the container.
bool mdds::trie_map< KeyTraits, ValueT >::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< KeyTraits, ValueT >::find | ( | const key_type & | key | ) |
Find a value associated with a specified key.
key | key to match. |
const_iterator mdds::trie_map< KeyTraits, ValueT >::find | ( | const key_type & | key | ) | const |
Find a value associated with a specified key.
key | key to match. |
iterator mdds::trie_map< KeyTraits, ValueT >::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< KeyTraits, ValueT >::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< KeyTraits, ValueT >::insert | ( | const key_type & | key, |
const value_type & | value | ||
) |
Insert a new key-value pair.
key | key value. |
value | value to associate with the key. |
void mdds::trie_map< KeyTraits, ValueT >::insert | ( | const key_unit_type * | key, |
size_type | len, | ||
const 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< KeyTraits, ValueT >::pack | ( | ) | const |
Create a compressed and immutable version of the container which provides better search performance and requires much less memory footprint.
search_results mdds::trie_map< KeyTraits, ValueT >::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< KeyTraits, ValueT >::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. |
size_type mdds::trie_map< KeyTraits, ValueT >::size | ( | ) | const |
Return the number of entries in the map.