Public Types | |
typedef hash_map< NameType, mootEnumID, NameHashFcn, NameEqualFcn > | Name2IdMap |
typedef vector< NameType > | Id2NameMap |
Public Member Functions | |
mootEnum (void) | |
mootEnum (const NameType &unknownName) | |
~mootEnum (void) | |
void | unknown_name (const NameType &name) |
bool | nameExists (const NameType &name) const |
bool | idExists (const mootEnumID id) const |
mootEnumID | size (void) const |
mootEnumID | name2id (const NameType &name) const |
const NameType & | id2name (const mootEnumID id) const |
mootEnumID | insert (const NameType &name, mootEnumID id=0) |
void | remove (const NameType &name, mootEnumID id=mootEnumNone) |
void | remove (mootEnumID id) |
mootEnumID | get_id (const NameType &name) |
void | clear (void) |
void | resize (size_t newsize) |
Public Attributes | |
Name2IdMap | names2ids |
maps names to IDs More... | |
Id2NameMap | ids2names |
maps IDs to names More... | |
Template class for runtime enumerations (symbolic_name<->unsigned_int maps) using STL hash_map<> and vector<>.
Currently just supports monotonically growing enumerations: no support for single-item removal or re-assignment.
Suggests: default constructor for NameType (for default mootEnum constructor).
Requires: g++ flag "-ftemplate-depth-NN", where NN >= 19 for compilation with gcc-2.95.4 using STLport-4.5.3.
typedef hash_map<NameType,mootEnumID,NameHashFcn,NameEqualFcn> mootEnum< NameType, NameHashFcn, NameEqualFcn >::Name2IdMap |
Type which maps symbolic names to numeric IDs
typedef vector<NameType> mootEnum< NameType, NameHashFcn, NameEqualFcn >::Id2NameMap |
Type which maps numeric IDs back to symbolic names
|
inline |
Default constructor
|
inline |
Default constructor
|
inline |
Default destructor
|
inline |
Set the 'unknown' name
Referenced by moot::mootHMM::unknown_tag_name(), and moot::mootHMM::unknown_token_name().
|
inline |
Check whether 'name' is a registered name.
|
inline |
Check whether 'id' is a registered id.
|
inline |
Return maximum id +1
|
inline |
Lookup ID for name, returns 0 if name is unregistered.
Referenced by moot::mootHMM::classp(), moot::mootHMM::tagp(), moot::mootHMM::token2id(), moot::mootHMM::viterbi_best_path(), moot::mootHMM::viterbi_step(), and moot::mootHMM::wordp().
|
inline |
Lookup name for id. Returns the "unknown" name if id is unregistered.
|
inline |
Insert a new name<->id mapping. If id is unspecified or zero, a new unique id will be assigned. Returns the (new) id.
|
inline |
Remove a name<->id mapping. Effectively re-maps name
to mootEnumNone==0 and id
to unknown_name() Will never shrink the object.
|
inline |
Remove a name<->id mapping, given only id
|
inline |
Get ID for name, creating one if it doesn't already exist.
|
inline |
Clears all mappings, but retains "unknown" name
|
inline |
Resize the object, leaving only newsize-1
IDs intact. Increasing object size may leave the object in an inconsistent state.
Name2IdMap mootEnum< NameType, NameHashFcn, NameEqualFcn >::names2ids |
Id2NameMap mootEnum< NameType, NameHashFcn, NameEqualFcn >::ids2names |