concordia-library/concordia/word_map.cpp
rjawor 2533fd5b44 extended markers - length, bitwise operators
Former-commit-id: 948a7fc68bf0b2284ce631d877fc13fa3eaa4882
2015-04-09 22:17:19 +02:00

28 lines
636 B
C++

#include "concordia/word_map.hpp"
#include <climits>
WordMap::WordMap() throw(ConcordiaException) {
_nextFree = 0;
}
WordMap::~WordMap() {
}
INDEX_CHARACTER_TYPE WordMap::getWordCode(const string & word)
throw(ConcordiaException) {
if (_map.find(word) == _map.end()) {
if (_nextFree == INDEX_CHARACTER_TYPE_MAX_VALUE) {
throw ConcordiaException("Word map capacity limit reached!");
}
INDEX_CHARACTER_TYPE newCode = _nextFree;
_map[word] = newCode;
_nextFree++;
return newCode;
} else {
return _map[word];
}
}