StringEncodingDictionary< int > Class Template Reference

Public Types

using MapType = std::array< size_t, 1<< CHAR_BIT >
 A convenient alias for the internal type of the map. More...

 
using TokenType = int
 The type of the token that the dictionary stores. More...

 

Public Member Functions

 StringEncodingDictionary ()
 Construct the default class. More...

 
size_t AddToken (const int 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 int token) const
 The function returns true if the dictionary contains the given token. More...

 
const MapTypeMapping () const
 Get the mapping. More...

 
MapTypeMapping ()
 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 int token) const
 The function returns the label assigned to the given token. More...

 

Detailed Description


template
<
>

class mlpack::data::StringEncodingDictionary< int >

Definition at line 256 of file string_encoding_dictionary.hpp.

Member Typedef Documentation

◆ MapType

using MapType = std::array<size_t, 1 << CHAR_BIT>

A convenient alias for the internal type of the map.

Definition at line 260 of file string_encoding_dictionary.hpp.

◆ TokenType

using TokenType = int

The type of the token that the dictionary stores.

Definition at line 263 of file string_encoding_dictionary.hpp.

Constructor & Destructor Documentation

◆ StringEncodingDictionary()

Construct the default class.

Definition at line 266 of file string_encoding_dictionary.hpp.

Member Function Documentation

◆ AddToken()

size_t AddToken ( const int  token)
inline

The function adds the given token to the dictionary and assigns a label to the token.

The token must belong to [0, 255]; otherwise the behavior is undefined. The label is equal to the resulting size of the dictionary. The function returns the assigned label.

Parameters
tokenThe given token.

Definition at line 291 of file string_encoding_dictionary.hpp.

◆ Clear()

void Clear ( )
inline

Clear the dictionary.

Definition at line 317 of file string_encoding_dictionary.hpp.

◆ HasToken()

bool HasToken ( const int  token) const
inline

The function returns true if the dictionary contains the given token.

The token must belong to [0, 255]; otherwise the behavior is undefined.

Parameters
tokenThe given token.

Definition at line 278 of file string_encoding_dictionary.hpp.

◆ Mapping() [1/2]

const MapType& Mapping ( ) const
inline

Get the mapping.

Definition at line 323 of file string_encoding_dictionary.hpp.

◆ Mapping() [2/2]

MapType& Mapping ( )
inline

Modify the mapping.

Definition at line 325 of file string_encoding_dictionary.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)
inline

Serialize the class to the given archive.

Definition at line 331 of file string_encoding_dictionary.hpp.

◆ Size()

size_t Size ( ) const
inline

Get the size of the dictionary.

Definition at line 311 of file string_encoding_dictionary.hpp.

◆ Value()

size_t Value ( const int  token) const
inline

The function returns the label assigned to the given token.

The function doesn't verify that the dictionary contains the token. The token must belong to [0, 255]; otherwise the behavior is undefined.

Parameters
tokenThe given token.

Definition at line 305 of file string_encoding_dictionary.hpp.


The documentation for this class was generated from the following file: