Poco::FastInfoset

template < class T >

class MapVocabulary

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

Description

A MapVocabulary 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

ConstIterator

typedef typename Data::const_iterator ConstIterator;

Data

typedef std::map < T, Poco::UInt32 > Data;

Index

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

Iterator

typedef typename Data::iterator Iterator;

Constructors

MapVocabulary inline

MapVocabulary();

Creates the MapVocabulary.

MapVocabulary inline

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.

Destructor

~MapVocabulary inline

~MapVocabulary();

Destroys the MapVocabulary.

Member Functions

clone inline

MapVocabulary < 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 MapVocabulary::Index & index() const;

operator - inline

MapVocabulary * operator - (
    const MapVocabulary & voc
) 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.