Library: FastInfoset
Package: FastInfoset
Header: Poco/FastInfoset/MapVocabulary.h
A MapVocabulary 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 typename Data::const_iterator ConstIterator;
typedef std::map < T, Poco::UInt32 > Data;
typedef std::vector < const T * > Index;
typedef typename Data::iterator Iterator;
 
 Creates the MapVocabulary.
 
 MapVocabulary(
    const typename Vocabulary < T >::DataVector & initialData
);
Creates the MapVocabulary and preloads it with the data in initialData. The index is assigned according to the position of the data in the vector.
 
 ~MapVocabulary();
Destroys the MapVocabulary.
 
 MapVocabulary < 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 MapVocabulary::Index & index() const;
 
 MapVocabulary * operator - (
    const MapVocabulary & voc
) 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.