mdds
|
#include <trie_map.hpp>
Public Types | |
typedef packed_trie_map< _KeyTrait, _ValueT > | packed_type |
typedef _KeyTrait | key_trait_type |
typedef key_trait_type::string_type | string_type |
typedef key_trait_type::buffer_type | buffer_type |
typedef key_trait_type::char_type | char_type |
typedef _ValueT | value_type |
typedef size_t | size_type |
typedef std::pair< string_type, value_type > | key_value_type |
Public Member Functions | |
trie_map ()=delete | |
trie_map (value_type null_value) | |
void | insert (const char_type *key, size_type len, const value_type &value) |
bool | erase (const char_type *key, size_type len) |
value_type | find (const char_type *input, size_type len) const |
std::vector< key_value_type > | prefix_search (const char_type *prefix, size_type len) const |
size_type | size () const |
void | clear () |
packed_type | pack () const |
Friends | |
class | packed_trie_map< _KeyTrait, _ValueT > |
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.
|
delete |
Not implemented.
mdds::trie_map< _KeyTrait, _ValueT >::trie_map | ( | value_type | null_value | ) |
Constructor.
null_value | null value to return when the find method fails to find a matching entry. |
void mdds::trie_map< _KeyTrait, _ValueT >::clear | ( | ) |
Empty the container.
bool mdds::trie_map< _KeyTrait, _ValueT >::erase | ( | const char_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. |
value_type mdds::trie_map< _KeyTrait, _ValueT >::find | ( | const char_type * | input, |
size_type | len | ||
) | const |
Find a value associated with a specified string key.
input | pointer to a C-style string whose value represents the key to match. |
len | length of the matching string value. |
void mdds::trie_map< _KeyTrait, _ValueT >::insert | ( | const char_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.
std::vector<key_value_type> mdds::trie_map< _KeyTrait, _ValueT >::prefix_search | ( | const char_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 a C-style string 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.