template<typename T>
liarsdice::data_structures::TrieMap class

High-performance Trie data structure for pattern storage.

Template parameters
T Value type to store at pattern endpoints

Uses Boost flat_map for cache-efficient child node storage. Optimized for storing and retrieving player behavior patterns.

Constructors, destructors, conversion operators

TrieMap()

Public functions

void insert(const std::string& pattern, T value)
Insert a pattern-value pair into the trie.
auto find(const std::string& pattern) const -> boost::optional<T>
Find a value by exact pattern match.
auto find_prefixes(const std::string& text) const -> std::vector<T>
Find all values with patterns that are prefixes of the input.
auto erase(const std::string& pattern) -> bool
Remove a pattern from the trie.
void clear()
Clear all patterns from the trie.
auto empty() const -> bool
Check if the trie is empty.
auto get_all() const -> std::vector<std::pair<std::string, T>>
Get all stored patterns and their values.

Function documentation

template<typename T>
void liarsdice::data_structures::TrieMap<T>::insert(const std::string& pattern, T value)

Insert a pattern-value pair into the trie.

Parameters
pattern The pattern string to insert
value The value to associate with the pattern

template<typename T>
boost::optional<T> liarsdice::data_structures::TrieMap<T>::find(const std::string& pattern) const

Find a value by exact pattern match.

Parameters
pattern The pattern to search for
Returns Optional containing the value if found

template<typename T>
std::vector<T> liarsdice::data_structures::TrieMap<T>::find_prefixes(const std::string& text) const

Find all values with patterns that are prefixes of the input.

Parameters
text The text to search within
Returns Vector of found values

template<typename T>
bool liarsdice::data_structures::TrieMap<T>::erase(const std::string& pattern)

Remove a pattern from the trie.

Parameters
pattern The pattern to remove
Returns True if the pattern was found and removed

template<typename T>
bool liarsdice::data_structures::TrieMap<T>::empty() const

Check if the trie is empty.

Returns True if no patterns are stored

template<typename T>
std::vector<std::pair<std::string, T>> liarsdice::data_structures::TrieMap<T>::get_all() const

Get all stored patterns and their values.

Returns Vector of pattern-value pairs