StringEncodingDictionary< boost::string_view > Class Template Reference

Public Types

using MapType = std::unordered_map< boost::string_view, size_t, boost::hash< boost::string_view > >
 A convenient alias for the internal type of the map. More...

 
using TokenType = boost::string_view
 The type of the token that the dictionary stores. More...

 

Public Member Functions

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

 
 StringEncodingDictionary (const StringEncodingDictionary &other)
 Copy the class from the given object. More...

 
 StringEncodingDictionary (StringEncodingDictionary &&other)=default
 Standard move constructor. More...

 
size_t AddToken (const boost::string_view 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 boost::string_view 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...

 
StringEncodingDictionaryoperator= (const StringEncodingDictionary &other)
 Copy the class from the given object. More...

 
StringEncodingDictionaryoperator= (StringEncodingDictionary &&other)=default
 Standard move assignment operator. More...

 
template
<
typename
Archive
>
void serialize (Archive &ar, const unsigned int)
 Serialize the class to the given archive. More...

 
size_t Size () const
 Get the size of the dictionary. More...

 
const std::deque< std::string > & Tokens () const
 Get the tokens. More...

 
std::deque< std::string > & Tokens ()
 Modify the tokens. More...

 
size_t Value (const boost::string_view token) const
 The function returns the label assigned to the given token. More...

 

Detailed Description


template
<
>

class mlpack::data::StringEncodingDictionary< boost::string_view >

Definition at line 111 of file string_encoding_dictionary.hpp.

Member Typedef Documentation

◆ MapType

using MapType = std::unordered_map< boost::string_view, size_t, boost::hash<boost::string_view> >

A convenient alias for the internal type of the map.

Definition at line 118 of file string_encoding_dictionary.hpp.

◆ TokenType

using TokenType = boost::string_view

The type of the token that the dictionary stores.

Definition at line 121 of file string_encoding_dictionary.hpp.

Constructor & Destructor Documentation

◆ StringEncodingDictionary() [1/3]

Construct the default class.

◆ StringEncodingDictionary() [2/3]

StringEncodingDictionary ( const StringEncodingDictionary< boost::string_view > &  other)
inline

Copy the class from the given object.

Definition at line 127 of file string_encoding_dictionary.hpp.

◆ StringEncodingDictionary() [3/3]

StringEncodingDictionary ( StringEncodingDictionary< boost::string_view > &&  other)
default

Standard move constructor.

Member Function Documentation

◆ AddToken()

size_t AddToken ( const boost::string_view  token)
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.

Parameters
tokenThe given token.

Definition at line 170 of file string_encoding_dictionary.hpp.

◆ Clear()

void Clear ( )
inline

Clear the dictionary.

Definition at line 196 of file string_encoding_dictionary.hpp.

◆ HasToken()

bool HasToken ( const boost::string_view  token) const
inline

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

Parameters
tokenThe given token.

Definition at line 158 of file string_encoding_dictionary.hpp.

◆ Mapping() [1/2]

const MapType& Mapping ( ) const
inline

Get the mapping.

Definition at line 208 of file string_encoding_dictionary.hpp.

◆ Mapping() [2/2]

MapType& Mapping ( )
inline

Modify the mapping.

Definition at line 210 of file string_encoding_dictionary.hpp.

◆ operator=() [1/2]

StringEncodingDictionary& operator= ( const StringEncodingDictionary< boost::string_view > &  other)
inline

Copy the class from the given object.

Definition at line 138 of file string_encoding_dictionary.hpp.

◆ operator=() [2/2]

StringEncodingDictionary& operator= ( StringEncodingDictionary< boost::string_view > &&  other)
default

Standard move assignment operator.

◆ serialize()

void serialize ( Archive &  ar,
const unsigned  int 
)
inline

Serialize the class to the given archive.

Definition at line 216 of file string_encoding_dictionary.hpp.

◆ Size()

size_t Size ( ) const
inline

Get the size of the dictionary.

Definition at line 193 of file string_encoding_dictionary.hpp.

◆ Tokens() [1/2]

const std::deque<std::string>& Tokens ( ) const
inline

Get the tokens.

Definition at line 203 of file string_encoding_dictionary.hpp.

◆ Tokens() [2/2]

std::deque<std::string>& Tokens ( )
inline

Modify the tokens.

Definition at line 205 of file string_encoding_dictionary.hpp.

◆ Value()

size_t Value ( const boost::string_view  token) const
inline

The function returns the label assigned to the given token.

The function throws std::out_of_range if no such token is found.

Parameters
tokenThe given token.

Definition at line 187 of file string_encoding_dictionary.hpp.


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