Poco::FastInfoset

template < class T >

class HashVocabulary

Library: FastInfoset
Package: FastInfoset
Header: Poco/FastInfoset/HashVocabulary.h

Description

A Vocabulary allows to map values to indices and vice versa. New values are automatically enqueued and assigned an index.

Member Summary

Member Functions: clone, empty, exists, index, operator -, size, value

Types

Data

typedef FISHashTable < T > Data;

Index

typedef std::vector < const T * > Index;

Constructors

HashVocabulary inline

HashVocabulary(
    Poco::UInt32 hashTableSize = 10009
);

Creates the Vocabulary.

HashVocabulary inline

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.

Destructor

~HashVocabulary inline

~HashVocabulary();

Destroys the Vocabulary.

Member Functions

clone inline

HashVocabulary < T > * clone() const;

Deep-copy

empty inline

bool empty() const;

exists inline

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.

index inline

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.

index inline

const typename HashVocabulary::Index & index() const;

operator - inline

HashVocabulary * operator - (
    const HashVocabulary & other
) const;

size inline

std::size_t size() const;

value inline

const T & value(
    Poco::UInt32 idx
) const;

Returns the value for the given index. Throws an exception if the idx is out of range.