concordia-library/concordia/word_map.cpp

23 lines
411 B
C++
Raw Normal View History

2013-11-12 22:08:37 +01:00
#include "concordia/word_map.hpp"
WordMap::WordMap() throw(ConcordiaException) {
_nextFree = 0;
}
WordMap::~WordMap() {
}
INDEX_CHARACTER_TYPE WordMap::getWordCode(const string & word) {
2013-11-14 15:44:50 +01:00
if (_map.find(word) == _map.end()) {
INDEX_CHARACTER_TYPE newCode = _nextFree;
2013-11-12 22:08:37 +01:00
_map[word] = newCode;
_nextFree++;
return newCode;
} else {
2013-11-14 15:44:50 +01:00
return _map[word];
2013-11-12 22:08:37 +01:00
}
}