diff --git a/honoka/plugins/wordsdic.cpp b/honoka/plugins/wordsdic.cpp index 2af1a0d..ed2f4d8 100644 --- a/honoka/plugins/wordsdic.cpp +++ b/honoka/plugins/wordsdic.cpp @@ -56,9 +56,9 @@ /*! \fn Honoka::WordsDic::find(const string &word) */ -vector Honoka::WordsDic::find(const string &word) +set Honoka::WordsDic::find(const string &word) { - vector res,bres; + set res,bres; if (fd == -1) return res; if (word.length() > 255) return res; if (fd == -1) return res; @@ -83,12 +83,12 @@ s += p[i]; } if (strncmp(ow,ob,word.length()) == 0) - res.push_back(s); - else bres.push_back(s); + res.insert(s); + else bres.insert(s); } while(*p != '\n') p ++; p ++; } - for(unsigned int i = 0;i < bres.size();i ++) res.push_back(bres[i]); + for(set::iterator it = bres.begin();it != bres.end();it ++) res.insert(*it); return res; } diff --git a/honoka/plugins/wordsdic.h b/honoka/plugins/wordsdic.h index 12df5c6..a911ded 100644 --- a/honoka/plugins/wordsdic.h +++ b/honoka/plugins/wordsdic.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -42,7 +42,7 @@ WordsDic(const string &filename); ~WordsDic(); - vector find(const string &word); + set find(const string &word); protected: int fd; diff --git a/honoka/plugins/wordsprediction.cpp b/honoka/plugins/wordsprediction.cpp index e766ca6..119baf8 100644 --- a/honoka/plugins/wordsprediction.cpp +++ b/honoka/plugins/wordsprediction.cpp @@ -72,7 +72,7 @@ if (!word.length()) return l; prewords = str.substr(0,str.length() - word.length()); pos = prewords.length(); - vector res = dic->find(utf8_wcstombs(word).c_str()); + set res = dic->find(utf8_wcstombs(word).c_str()); if (res.size() > limit) { l.Title = utf8_mbstowcs(String(_("too many prediction results!"))); l.kType = PREDICTION; @@ -84,7 +84,7 @@ } else { l.Title = utf8_mbstowcs(String(_("lookup result"))); l.kType = PREDICTION; - for(vector::iterator it = res.begin();it != res.end();it ++) { + for(set::iterator it = res.begin();it != res.end();it ++) { if (addSpace) l.kouho.push_back(ResultEntry(prewords + utf8_mbstowcs(*it) + utf8_mbstowcs(" "),utf8_mbstowcs(*it))); else l.kouho.push_back(ResultEntry(prewords + utf8_mbstowcs(*it),utf8_mbstowcs(*it))); }