mdds
|
#include <trie_map.hpp>
Public Types | |
typedef packed_trie_map< _KeyTrait, _ValueT > | packed_type |
typedef _KeyTrait | key_trait_type |
typedef key_trait_type::key_type | key_type |
typedef key_trait_type::key_buffer_type | key_buffer_type |
typedef key_trait_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 |
typedef trie::detail::iterator_base< trie_map > | const_iterator |
typedef trie::detail::search_results< trie_map > | search_results |
Public Member Functions | |
trie_map () | |
const_iterator | begin () const |
const_iterator | end () const |
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 |
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 |
void | clear () |
packed_type | pack () const |
Friends | |
class | packed_trie_map< _KeyTrait, _ValueT > |
class | trie::detail::iterator_base< trie_map > |
class | trie::detail::search_results< trie_map > |
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< _KeyTrait, _ValueT >::trie_map | ( | ) |
Default constructor.
void mdds::trie_map< _KeyTrait, _ValueT >::clear | ( | ) |
Empty the container.
bool mdds::trie_map< _KeyTrait, _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. |
const_iterator mdds::trie_map< _KeyTrait, _ValueT >::find | ( | const key_type & | key | ) | const |
Find a value associated with a specified key.
key | key to match. |
const_iterator mdds::trie_map< _KeyTrait, _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< _KeyTrait, _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< _KeyTrait, _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< _KeyTrait, _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< _KeyTrait, _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< _KeyTrait, _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< _KeyTrait, _ValueT >::size | ( | ) | const |
Return the number of entries in the map.