eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot dic/dic.h dic/dic_search.cpp dic/regexpma...


From: eliot-dev
Subject: [Eliot-dev] eliot dic/dic.h dic/dic_search.cpp dic/regexpma...
Date: Sun, 02 Mar 2008 18:45:11 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Olivier Teulière <ipkiss>      08/03/02 18:45:11

Modified files:
        dic            : dic.h dic_search.cpp regexpmain.cpp 
        utils          : eliottxt.cpp 
        wxwin          : auxframes.cc searchpanel.cc 

Log message:
         - Use vectors instead of lists to store the results of dictionary 
searches
         - New parameter to most search functions, allowing to limit the number 
of results.
           No interface uses it yet.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic.h?cvsroot=eliot&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic_search.cpp?cvsroot=eliot&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/regexpmain.cpp?cvsroot=eliot&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/eliottxt.cpp?cvsroot=eliot&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/eliot/wxwin/auxframes.cc?cvsroot=eliot&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/eliot/wxwin/searchpanel.cc?cvsroot=eliot&r1=1.16&r2=1.17

Patches:
Index: dic/dic.h
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- dic/dic.h   8 Jan 2008 13:52:34 -0000       1.14
+++ dic/dic.h   2 Mar 2008 18:45:10 -0000       1.15
@@ -183,31 +183,38 @@
      * Search for benjamins
      * @param iWord: letters
      * @param oWordList: results
+     * @param iMaxResults: maximum number of returned results (0 means no 
limit)
      */
-    void searchBenj(const wstring &iWord, list<wstring> &oWordList) const;
+    void searchBenj(const wstring &iWord, vector<wstring> &oWordList,
+                    unsigned int iMaxResults = 0) const;
 
     /**
      * Search for all words feasible by adding a letter in front or at the end
      * @param iWord: word
      * @param oWordList: results
+     * @param iMaxResults: maximum number of returned results (0 means no 
limit)
      */
-    void searchRacc(const wstring &iWord, list<wstring> &oWordList) const;
+    void searchRacc(const wstring &iWord, vector<wstring> &oWordList,
+                    unsigned int iMaxResults = 0) const;
 
     /**
      * Search for crosswords
      * @param iMask: letters
      * @param oWordList: results
+     * @param iMaxResults: maximum number of returned results (0 means no 
limit)
      */
-    void searchCross(const wstring &iMask, list<wstring> &oWordList) const;
+    void searchCross(const wstring &iMask, vector<wstring> &oWordList,
+                     unsigned int iMaxResults = 0) const;
 
     /**
      * Search for all feasible word with "rack" plus one letter
      * @param iRack: letters
      * @param oWordlist: results
      * @param joker: true if the search must be performed when a joker is in 
the rack
+     * @param iMaxResults: maximum number of returned results (0 means no 
limit)
      */
     void search7pl1(const wstring &iRack,
-                    map<wchar_t, list<wstring> > &oWordList,
+                    map<wchar_t, vector<wstring> > &oWordList,
                     bool joker) const;
 
     /**
@@ -215,11 +222,12 @@
      * @param iRegexp: regular expression
      * @param oWordList: results
      * @param iList: parameters for the search (?)
+     * @param iMaxResults: maximum number of returned results (0 means no 
limit)
      */
     void searchRegExp(const wstring &iRegexp,
-                      list<wstring> &oWordList,
-                      struct search_RegE_list_t *iList) const;
-
+                      vector<wstring> &oWordList,
+                      struct search_RegE_list_t *iList,
+                      unsigned int iMaxResults = 0) const;
 
 
 private:
@@ -258,22 +266,25 @@
 
     /// Helper for searchBenj()
     template <typename DAWG_EDGE>
-    void searchBenjTempl(const wstring &iWord, list<wstring> &oWordList) const;
+    void searchBenjTempl(const wstring &iWord, vector<wstring> &oWordList,
+                         unsigned int iMaxResults) const;
 
     /// Helper for searchRacc()
     template <typename DAWG_EDGE>
-    void searchRaccTempl(const wstring &iWord, list<wstring> &oWordList) const;
+    void searchRaccTempl(const wstring &iWord, vector<wstring> &oWordList,
+                         unsigned int iMaxResults) const;
 
     /// Helper for searchCross()
     template <typename DAWG_EDGE>
     void searchCrossRecTempl(struct params_cross_t *params,
-                             list<wstring> &oWordList,
-                             const DAWG_EDGE *edgeptr) const;
+                             vector<wstring> &oWordList,
+                             const DAWG_EDGE *edgeptr,
+                             unsigned int iMaxResults) const;
 
     /// Helper for search7pl1()
     template <typename DAWG_EDGE>
     void search7pl1Templ(const wstring &iRack,
-                         map<wchar_t, list<wstring> > &oWordList,
+                         map<wchar_t, vector<wstring> > &oWordList,
                          bool joker) const;
 
     /// Second helper for search7pl1()
@@ -286,15 +297,17 @@
      * wide chars are supported by our regexp engine.
      */
     void searchRegExpInner(const string &iRegexp,
-                           list<string> &oWordList,
-                           struct search_RegE_list_t *iList) const;
+                           vector<string> &oWordList,
+                           struct search_RegE_list_t *iList,
+                           unsigned int iMaxResults) const;
 
     /// Helper for searchRegExp()
     template <typename DAWG_EDGE>
     void searchRegexpRecTempl(struct params_regexp_t *params,
                               int state,
                               const DAWG_EDGE *edgeptr,
-                              list<string> &oWordList) const;
+                              vector<string> &oWordList,
+                              unsigned int iMaxResults) const;
 };
 
 #endif /* _DIC_H_ */

Index: dic/dic_search.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic_search.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- dic/dic_search.cpp  19 Jan 2008 21:34:58 -0000      1.3
+++ dic/dic_search.cpp  2 Mar 2008 18:45:10 -0000       1.4
@@ -40,6 +40,9 @@
 #include "automaton.h"
 
 
+static const unsigned int DEFAULT_VECT_ALLOC = 100;
+
+
 /**
  * Function prototype for bison generated parser
  */
@@ -98,7 +101,7 @@
 struct params_7plus1_t
 {
     wchar_t added_char;
-    map<wchar_t, list<wstring> > *results;
+    map<wchar_t, vector<wstring> > *results;
     int search_len;
     wchar_t search_wordtst[DIC_WORD_MAX];
     char search_letters[63];
@@ -160,7 +163,7 @@
 
 template <typename DAWG_EDGE>
 void Dictionary::search7pl1Templ(const wstring &iRack,
-                                 map<wchar_t, list<wstring> > &oWordList,
+                                 map<wchar_t, vector<wstring> > &oWordList,
                                  bool joker) const
 {
     if (iRack == L"" || iRack.size() > DIC_WORD_MAX)
@@ -230,7 +233,7 @@
 
 
 void Dictionary::search7pl1(const wstring &iRack,
-                            map<wchar_t, list<wstring> > &oWordList,
+                            map<wchar_t, vector<wstring> > &oWordList,
                             bool joker) const
 {
     if (getHeader().getVersion() == 0)
@@ -243,14 +246,19 @@
 /****************************************/
 
 template <typename DAWG_EDGE>
-void Dictionary::searchRaccTempl(const wstring &iWord, list<wstring> 
&oWordList) const
+void Dictionary::searchRaccTempl(const wstring &iWord, vector<wstring> 
&oWordList,
+                                 unsigned int iMaxResults) const
 {
     if (iWord == L"")
         return;
 
-    /* search_racc will try to add a letter in front and at the end of a word 
*/
+    // Allocate room for all the results
+    if (iMaxResults)
+        oWordList.reserve(iMaxResults);
+    else
+        oWordList.reserve(DEFAULT_VECT_ALLOC);
 
-    /* let's try for the front */
+    // Try to add a letter at the front
     wchar_t wordtst[DIC_WORD_MAX];
     wcscpy(wordtst + 1, iWord.c_str());
     const wstring &letters = getHeader().getLetters();
@@ -259,9 +267,11 @@
         wordtst[0] = letters[i];
         if (searchWord(wordtst))
             oWordList.push_back(wordtst);
+        if (iMaxResults && oWordList.size() >= iMaxResults)
+            return;
     }
 
-    /* add a letter at the end */
+    // Try to add a letter at the end
     int i;
     for (i = 0; iWord[i]; i++)
         wordtst[i] = iWord[i];
@@ -283,29 +293,38 @@
             {
                 wordtst[i] = getHeader().getCharFromCode(edge->chr);
                 oWordList.push_back(wordtst);
+                if (iMaxResults && oWordList.size() >= iMaxResults)
+                    return;
             }
         } while (!(*edge++).last);
     }
 }
 
 
-void Dictionary::searchRacc(const wstring &iWord, list<wstring> &oWordList) 
const
+void Dictionary::searchRacc(const wstring &iWord, vector<wstring> &oWordList, 
unsigned int iMaxResults) const
 {
     if (getHeader().getVersion() == 0)
-        searchRaccTempl<DicEdgeOld>(iWord, oWordList);
+        searchRaccTempl<DicEdgeOld>(iWord, oWordList, iMaxResults);
     else
-        searchRaccTempl<DicEdge>(iWord, oWordList);
+        searchRaccTempl<DicEdge>(iWord, oWordList, iMaxResults);
 }
 
 /****************************************/
 /****************************************/
 
 template <typename DAWG_EDGE>
-void Dictionary::searchBenjTempl(const wstring &iWord, list<wstring> 
&oWordList) const
+void Dictionary::searchBenjTempl(const wstring &iWord, vector<wstring> 
&oWordList,
+                                 unsigned int iMaxResults) const
 {
     if (iWord == L"")
         return;
 
+    // Allocate room for all the results
+    if (iMaxResults)
+        oWordList.reserve(iMaxResults);
+    else
+        oWordList.reserve(DEFAULT_VECT_ALLOC);
+
     wchar_t wordtst[DIC_WORD_MAX];
     wcscpy(wordtst + 3, iWord.c_str());
     const DAWG_EDGE *edge0, *edge1, *edge2, *edgetst;
@@ -326,6 +345,8 @@
                 {
                     wordtst[2] = getHeader().getCharFromCode(edge2->chr);
                     oWordList.push_back(wordtst);
+                    if (iMaxResults && oWordList.size() >= iMaxResults)
+                        return;
                 }
             } while (!(*edge2++).last);
         } while (!(*edge1++).last);
@@ -333,12 +354,13 @@
 }
 
 
-void Dictionary::searchBenj(const wstring &iWord, list<wstring> &oWordList) 
const
+void Dictionary::searchBenj(const wstring &iWord, vector<wstring> &oWordList,
+                            unsigned int iMaxResults) const
 {
     if (getHeader().getVersion() == 0)
-        searchBenjTempl<DicEdgeOld>(iWord, oWordList);
+        searchBenjTempl<DicEdgeOld>(iWord, oWordList, iMaxResults);
     else
-        searchBenjTempl<DicEdge>(iWord, oWordList);
+        searchBenjTempl<DicEdge>(iWord, oWordList, iMaxResults);
 }
 
 /****************************************/
@@ -353,9 +375,13 @@
 
 template <typename DAWG_EDGE>
 void Dictionary::searchCrossRecTempl(struct params_cross_t *params,
-                                     list<wstring> &oWordList,
-                                     const DAWG_EDGE *edgeptr) const
+                                     vector<wstring> &oWordList,
+                                     const DAWG_EDGE *edgeptr,
+                                     unsigned int iMaxResults) const
 {
+    if (iMaxResults && oWordList.size() >= iMaxResults)
+        return;
+
     const DAWG_EDGE *current = getEdgeAt<DAWG_EDGE>(edgeptr->ptr);
 
     if (params->mask[params->wordlen] == '\0')
@@ -374,7 +400,7 @@
         {
             params->mask[params->wordlen] = 
getHeader().getCharFromCode(current->chr);
             params->wordlen ++;
-            searchCrossRecTempl(params, oWordList, current);
+            searchCrossRecTempl(params, oWordList, current, iMaxResults);
             params->wordlen --;
             params->mask[params->wordlen] = '.';
         }
@@ -387,7 +413,7 @@
             if (current->chr == 
getHeader().getCodeFromChar(params->mask[params->wordlen]))
             {
                 params->wordlen ++;
-                searchCrossRecTempl(params, oWordList, current);
+                searchCrossRecTempl(params, oWordList, current, iMaxResults);
                 params->wordlen --;
                 break;
             }
@@ -397,11 +423,18 @@
 }
 
 
-void Dictionary::searchCross(const wstring &iMask, list<wstring> &oWordList) 
const
+void Dictionary::searchCross(const wstring &iMask, vector<wstring> &oWordList,
+                             unsigned int iMaxResults) const
 {
     if (iMask == L"")
         return;
 
+    // Allocate room for all the results
+    if (iMaxResults)
+        oWordList.reserve(iMaxResults);
+    else
+        oWordList.reserve(DEFAULT_VECT_ALLOC);
+
     struct params_cross_t params;
 
     int i;
@@ -418,12 +451,12 @@
     if (getHeader().getVersion() == 0)
     {
         searchCrossRecTempl(&params, oWordList,
-                            getEdgeAt<DicEdgeOld>(getRoot()));
+                            getEdgeAt<DicEdgeOld>(getRoot()), iMaxResults);
     }
     else
     {
         searchCrossRecTempl(&params, oWordList,
-                            getEdgeAt<DicEdge>(getRoot()));
+                            getEdgeAt<DicEdge>(getRoot()), iMaxResults);
     }
 }
 
@@ -445,8 +478,12 @@
 void Dictionary::searchRegexpRecTempl(struct params_regexp_t *params,
                                       int state,
                                       const DAWG_EDGE *edgeptr,
-                                      list<string> &oWordList) const
+                                      vector<string> &oWordList,
+                                      unsigned int iMaxResults) const
 {
+    if (iMaxResults && oWordList.size() >= iMaxResults)
+        return;
+
     int next_state;
     /* if we have a valid word we store it */
     if (params->automaton_field->accept(state) && edgeptr->term)
@@ -469,7 +506,7 @@
         {
             params->word[params->wordlen] = current->chr + 'a' - 1;
             params->wordlen ++;
-            searchRegexpRecTempl(params, next_state, current, oWordList);
+            searchRegexpRecTempl(params, next_state, current, oWordList, 
iMaxResults);
             params->wordlen --;
             params->word[params->wordlen] = '\0';
         }
@@ -478,9 +515,16 @@
 
 
 void Dictionary::searchRegExpInner(const string &iRegexp,
-                                   list<string> &oWordList,
-                                   struct search_RegE_list_t *iList) const
+                                   vector<string> &oWordList,
+                                   struct search_RegE_list_t *iList,
+                                   unsigned int iMaxResults) const
 {
+    // Allocate room for all the results
+    if (iMaxResults)
+        oWordList.reserve(iMaxResults);
+    else
+        oWordList.reserve(DEFAULT_VECT_ALLOC);
+
     int ptl[REGEXP_MAX+1];
     int PS [REGEXP_MAX+1];
 
@@ -538,12 +582,12 @@
         if (getHeader().getVersion() == 0)
         {
             searchRegexpRecTempl(&params, a->getInitId(),
-                                 getEdgeAt<DicEdgeOld>(getRoot()), oWordList);
+                                 getEdgeAt<DicEdgeOld>(getRoot()), oWordList, 
iMaxResults);
         }
         else
         {
             searchRegexpRecTempl(&params, a->getInitId(),
-                                 getEdgeAt<DicEdge>(getRoot()), oWordList);
+                                 getEdgeAt<DicEdge>(getRoot()), oWordList, 
iMaxResults);
         }
 
         delete a;
@@ -553,17 +597,24 @@
 
 
 void Dictionary::searchRegExp(const wstring &iRegexp,
-                              list<wstring> &oWordList,
-                              struct search_RegE_list_t *iList) const
+                              vector<wstring> &oWordList,
+                              struct search_RegE_list_t *iList,
+                              unsigned int iMaxResults) const
 {
     if (iRegexp == L"")
         return;
 
-    list<string> tmpWordList;
+    // Allocate room for all the results
+    if (iMaxResults)
+        oWordList.reserve(iMaxResults);
+    else
+        oWordList.reserve(DEFAULT_VECT_ALLOC);
+
+    vector<string> tmpWordList;
     // Do the actual work
-    searchRegExpInner(convertToMb(iRegexp), tmpWordList, iList);
+    searchRegExpInner(convertToMb(iRegexp), tmpWordList, iList, iMaxResults);
 
-    list<string>::const_iterator it;
+    vector<string>::const_iterator it;
     for (it = tmpWordList.begin(); it != tmpWordList.end(); it++)
     {
         oWordList.push_back(convertToWc(*it));

Index: dic/regexpmain.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/regexpmain.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- dic/regexpmain.cpp  8 Jan 2008 13:52:36 -0000       1.2
+++ dic/regexpmain.cpp  2 Mar 2008 18:45:11 -0000       1.3
@@ -143,11 +143,11 @@
 
             /* automaton */
             init_letter_lists(&regList);
-            list<wstring> wordList;
+            vector<wstring> wordList;
             dic.searchRegExp(convertToWc(er), wordList, &regList);
 
             cout << _("result:") << endl;
-            list<wstring>::const_iterator it;
+            vector<wstring>::const_iterator it;
             for (it = wordList.begin(); it != wordList.end(); it++)
             {
                 cerr << convertToMb(*it) << endl;

Index: utils/eliottxt.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/eliottxt.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- utils/eliottxt.cpp  28 Jan 2008 19:17:37 -0000      1.20
+++ utils/eliottxt.cpp  2 Mar 2008 18:45:11 -0000       1.21
@@ -192,10 +192,10 @@
 
 void eliottxt_get_cross(const Dictionary &iDic, const wstring &iCros)
 {
-    list<wstring> wordList;
+    vector<wstring> wordList;
     iDic.searchCross(iCros, wordList);
 
-    list<wstring>::const_iterator it;
+    vector<wstring>::const_iterator it;
     for (it = wordList.begin(); it != wordList.end(); it++)
     {
         printf("  %s\n", convertToMb(*it).c_str());
@@ -429,23 +429,23 @@
                             {
                                 case L'b':
                                 {
-                                    list<wstring> wordList;
+                                    vector<wstring> wordList;
                                     iGame.getDic().searchBenj(word, wordList);
-                                    list<wstring>::const_iterator it;
+                                    vector<wstring>::const_iterator it;
                                     for (it = wordList.begin(); it != 
wordList.end(); ++it)
                                         cout << convertToMb(*it) << endl;
                                     break;
                                 }
                                 case L'p':
                                 {
-                                    map<wchar_t, list<wstring> > wordMap;
+                                    map<wchar_t, vector<wstring> > wordMap;
                                     iGame.getDic().search7pl1(word, wordMap, 
false);
-                                    map<wchar_t, list<wstring> 
>::const_iterator it;
+                                    map<wchar_t, vector<wstring> 
>::const_iterator it;
                                     for (it = wordMap.begin(); it != 
wordMap.end(); ++it)
                                     {
                                         if (it->first)
                                             cout << "+" << 
convertToMb(it->first) << endl;
-                                        list<wstring>::const_iterator itWord;;
+                                        vector<wstring>::const_iterator 
itWord;;
                                         for (itWord = it->second.begin(); 
itWord != it->second.end(); itWord++)
                                         {
                                             cout << "  " << 
convertToMb(*itWord) << endl;
@@ -455,9 +455,9 @@
                                 }
                                 case L'r':
                                 {
-                                    list<wstring> wordList;
+                                    vector<wstring> wordList;
                                     iGame.getDic().searchRacc(word, wordList);
-                                    list<wstring>::const_iterator it;
+                                    vector<wstring>::const_iterator it;
                                     for (it = wordList.begin(); it != 
wordList.end(); ++it)
                                         cout << convertToMb(*it) << endl;
                                     break;
@@ -876,11 +876,11 @@
     printf("search for %s (%d,%d,%d)\n", convertToMb(regexp).c_str(),
            nres, lmin, lmax);
 
-    list<wstring> wordList;
+    vector<wstring> wordList;
     iDic.searchRegExp(regexp, wordList, &llist);
 
     int nresult = 0;
-    list<wstring>::const_iterator it;
+    vector<wstring>::const_iterator it;
     for (it = wordList.begin(); it != wordList.end() && nresult < nres; it++)
     {
         printf("%s\n", convertToMb(*it).c_str());

Index: wxwin/auxframes.cc
===================================================================
RCS file: /cvsroot/eliot/eliot/wxwin/auxframes.cc,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- wxwin/auxframes.cc  12 Jan 2008 20:42:26 -0000      1.25
+++ wxwin/auxframes.cc  2 Mar 2008 18:45:11 -0000       1.26
@@ -26,7 +26,6 @@
 
 #include <iostream>
 #include <sstream>
-#include <list>
 #include <string>
 
 #include "wx/sizer.h"
@@ -390,12 +389,12 @@
     }
     savedword = rack;
 
-    map<wchar_t, list<wstring> > wordList;
+    map<wchar_t, vector<wstring> > wordList;
     game->getDic().search7pl1(rack, wordList, config.getJokerPlus1());
 
     // Count the results
     int sum = 0;
-    map<wchar_t, list<wstring> >::const_iterator it;
+    map<wchar_t, vector<wstring> >::const_iterator it;
     for (it = wordList.begin(); it != wordList.end(); it++)
     {
         if (it->first)
@@ -417,7 +416,7 @@
     {
         if (it->first)
             res[resnum++] = wxString(wxT("+")) + wxU((wxString)it->first);
-        list<wstring>::const_iterator itWord;
+        vector<wstring>::const_iterator itWord;
         for (itWord = it->second.begin(); itWord != it->second.end(); itWord++)
         {
             res[resnum++] = wxString(wxT("  ")) + wxU(itWord->c_str());
@@ -452,12 +451,12 @@
     }
     savedword = word;
     //debug("   BenjFrame::refresh : %s\n",word.c_str());
-    list<wstring> wordList;
+    vector<wstring> wordList;
     game->getDic().searchBenj(word, wordList);
 
     wxString *res = new wxString[wordList.size()];
     int resnum = 0;
-    list<wstring>::const_iterator it;
+    vector<wstring>::const_iterator it;
     for (it = wordList.begin(); it != wordList.end(); it++)
     {
         res[resnum++] = wxU(it->c_str());
@@ -493,12 +492,12 @@
     }
     savedword = word;
     //debug("   RaccFrame::refresh : %s\n",word.c_str());
-    list<wstring> wordList;
+    vector<wstring> wordList;
     game->getDic().searchRacc(word, wordList);
 
     wxString *res = new wxString[wordList.size()];
     int resnum = 0;
-    list<wstring>::const_iterator it;
+    vector<wstring>::const_iterator it;
     for (it = wordList.begin(); it != wordList.end(); it++)
     {
         res[resnum++] = wxU(it->c_str());

Index: wxwin/searchpanel.cc
===================================================================
RCS file: /cvsroot/eliot/eliot/wxwin/searchpanel.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- wxwin/searchpanel.cc        8 Jan 2008 13:52:43 -0000       1.16
+++ wxwin/searchpanel.cc        2 Mar 2008 18:45:11 -0000       1.17
@@ -151,12 +151,12 @@
     wchar_t rack[DIC_WORD_MAX];
     wcsncpy(rack, t->GetValue().wc_str(), DIC_WORD_MAX);
 
-    list<wstring> wordList;
+    vector<wstring> wordList;
     dic->searchCross(rack, wordList);
 
     int resnum = 0;
     wxString *res = new wxString[wordList.size()];
-    list<wstring>::const_iterator it;
+    vector<wstring>::const_iterator it;
     for (it = wordList.begin(); it != wordList.end(); it++)
         res[resnum++] =  wxU(it->c_str());
     l->Set(resnum,res);
@@ -193,12 +193,12 @@
     }
 
     wstring rack = t->GetValue().wc_str();
-    map<wchar_t, list<wstring> > wordList;
+    map<wchar_t, vector<wstring> > wordList;
     dic->search7pl1(rack, wordList, true);
 
     // Count the results
     int sum = 0;
-    map<wchar_t, list<wstring> >::const_iterator it;
+    map<wchar_t, vector<wstring> >::const_iterator it;
     for (it = wordList.begin(); it != wordList.end(); it++)
     {
         if (it->first)
@@ -212,7 +212,7 @@
     {
         if (it->first)
             res[resnum++] = wxString(wxT("+")) + wxU((wxString)it->first);
-        list<wstring>::const_iterator itWord;
+        vector<wstring>::const_iterator itWord;
         for (itWord = it->second.begin(); itWord != it->second.end(); itWord++)
         {
             res[resnum++] = wxString(wxT("  ")) + wxU(itWord->c_str());
@@ -245,10 +245,7 @@
 void
 PRegExp::build_letter_lists()
 {
-  int i;
-  std::list<Tile> all_tiles;
-
-  memset (&llist,0,sizeof(llist));
+  memset (&llist, 0, sizeof(llist));
 
   llist.minlength = 1;
   llist.maxlength = 15;
@@ -265,7 +262,7 @@
   llist.valid[3] = 0; // user defined list 1
   llist.valid[4] = 0; // user defined list 2
 
-  for(i=0; i < DIC_SEARCH_REGE_LIST; i++)
+  for(int i = 0; i < DIC_SEARCH_REGE_LIST; i++)
     {
       memset(llist.letters[i],0,sizeof(llist.letters[i]));
     }
@@ -341,12 +338,12 @@
     }
     debug("\n");
 
-    list<wstring> wordList;
+    vector<wstring> wordList;
     dic->searchRegExp(regexp, wordList, &llist);
 
     wxString *res = new wxString[wordList.size()];
     int resnum = 0;
-    list<wstring>::const_iterator it;
+    vector<wstring>::const_iterator it;
     for (it = wordList.begin(); it != wordList.end(); it++)
     {
         res[resnum++] =  wxU(it->c_str());




reply via email to

[Prev in Thread] Current Thread [Next in Thread]