iphreeqc/phreeqcpp/Dictionary.cpp
Scott Charlton 1d5c59a175 Add 'phreeqcpp/' from commit 'da9d06b423a87ed5eae503c0faf779ac11c96027'
git-subtree-dir: phreeqcpp
git-subtree-mainline: ba5f2ba885b4cc757201e28f9b4dce158f7cc66b
git-subtree-split: da9d06b423a87ed5eae503c0faf779ac11c96027
2018-07-31 16:56:09 -06:00

33 lines
597 B
C++

#include "Dictionary.h"
Dictionary::Dictionary(void)
{
}
Dictionary::Dictionary(std::string & words_string)
{
std::istringstream words_stream(words_string);
char str[256];
while (words_stream.getline(str,256))
{
this->Find(str);
}
}
Dictionary::~Dictionary(void)
{
}
int
Dictionary::Find(std::string str)
{
std::map<std::string, int>::iterator it = this->dictionary_map.find(str);
if (it != this->dictionary_map.end())
{
return it->second;
}
int i = this->MapSize();
this->dictionary_map[str] = i;
this->words.push_back(str);
this->dictionary_oss << str << "\n";
return i;
}