Library: FastInfoset
Package: FastInfoset
Header: Poco/FastInfoset/HashVocabulary.h
A Vocabulary allows to map values to indices and vice versa. New values are automatically enqueued and assigned an index.
Member Functions: clone, empty, exists, index, operator -, size, value
typedef FISHashTable < T > Data;
typedef std::vector < const T * > Index;
HashVocabulary(
Poco::UInt32 hashTableSize = 10009
);
Creates the Vocabulary.
HashVocabulary(
const typename Vocabulary < T >::DataVector & initialData,
Poco::UInt32 hashTableSize = 10009
);
Creates the Vocabulary and preloads it with the data in initialData. The index is assigned according to the position of the data in the vector.
~HashVocabulary();
Destroys the Vocabulary.
HashVocabulary < T > * clone() const;
Deep-copy
bool empty() const;
Poco::UInt32 exists(
const T & value,
bool & valueExisted
) const;
Returns the index for the given value. Sets valueExisted to false if the value did not exist.
Poco::UInt32 index(
const T & value,
bool & valueExisted
);
Returns the index for the given value. Automatically appends the value and assigns it a new index if the value does not exist yet. Query valueExisted to find out if the value already existed.
const typename HashVocabulary::Index & index() const;
HashVocabulary * operator - (
const HashVocabulary & other
) const;
std::size_t size() const;
const T & value(
Poco::UInt32 idx
) const;
Returns the value for the given index. Throws an exception if the idx is out of range.