This class provides a dictionary interface for the purpose of string encoding. More...
Public Types | |
using | MapType = std::unordered_map< Token, size_t > |
A convenient alias for the internal type of the map. More... | |
using | TokenType = Token |
The type of the token that the dictionary stores. More... | |
Public Member Functions | |
template < typename T > | |
size_t | AddToken (T &&token) |
The function adds the given token to the dictionary and assigns a label to the token. More... | |
void | Clear () |
Clear the dictionary. More... | |
bool | HasToken (const Token &token) const |
The function returns true if the dictionary contains the given token. More... | |
const MapType & | Mapping () const |
Get the mapping. More... | |
MapType & | Mapping () |
Modify the mapping. More... | |
template < typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the class to the given archive. More... | |
size_t | Size () const |
Get the size of the dictionary. More... | |
size_t | Value (const Token &token) const |
The function returns the label assigned to the given token. More... | |
This class provides a dictionary interface for the purpose of string encoding.
It works like an adapter to the internal dictionary.
Token | Type of the token that the dictionary stores. |
Definition at line 32 of file string_encoding_dictionary.hpp.
using MapType = std::unordered_map<Token, size_t> |
A convenient alias for the internal type of the map.
Definition at line 36 of file string_encoding_dictionary.hpp.
using TokenType = Token |
The type of the token that the dictionary stores.
Definition at line 39 of file string_encoding_dictionary.hpp.
|
inline |
The function adds the given token to the dictionary and assigns a label to the token.
The label is equal to the resulting size of the dictionary. The function returns the assigned label.
token | The given token. |
Definition at line 59 of file string_encoding_dictionary.hpp.
|
inline |
Clear the dictionary.
Definition at line 83 of file string_encoding_dictionary.hpp.
|
inline |
The function returns true if the dictionary contains the given token.
token | The given token. |
Definition at line 46 of file string_encoding_dictionary.hpp.
|
inline |
Get the mapping.
Definition at line 89 of file string_encoding_dictionary.hpp.
|
inline |
Modify the mapping.
Definition at line 91 of file string_encoding_dictionary.hpp.
|
inline |
Serialize the class to the given archive.
Definition at line 97 of file string_encoding_dictionary.hpp.
|
inline |
Get the size of the dictionary.
Definition at line 80 of file string_encoding_dictionary.hpp.
|
inline |
The function returns the label assigned to the given token.
The function throws std::out_of_range if no such token is found.
token | The given token. |
Definition at line 74 of file string_encoding_dictionary.hpp.