Sorted String Map
API Reference
-
template<typename ValueT, template<typename, typename> class EntryT = chars_map_entry>
class sorted_string_map sorted_string_map provides an efficient way to map string keys to arbitrary values, provided that the keys are known at compile time and are sorted in ascending order.
Public Types
-
using size_type = std::size_t
Public Functions
-
sorted_string_map(const entry *entries, size_type entry_size, value_type null_value)
Constructor.
- Parameters:
entries – pointer to the array of key-value entries.
entry_size – size of the key-value entry array.
null_value – null value to return when the find method fails to find a matching entry.
-
value_type find(const char *input, size_type len) const
Find a value associated with a specified string key.
- Parameters:
input – pointer to a C-style string whose value represents the key to match.
len – length of the matching string value.
- Returns:
value associated with the key, or the null value in case the key is not found.
-
value_type find(std::string_view input) const
Find a value associated with a specified string key.
- Parameters:
input – string key to match.
- Returns:
value associated with the key, or the null value in case the key is not found.
-
using size_type = std::size_t