[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot dic/dic.h dic/dic_search.cpp qt/dic_tools...
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot dic/dic.h dic/dic_search.cpp qt/dic_tools... |
Date: |
Mon, 21 Sep 2009 20:10:34 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 09/09/21 20:10:34
Modified files:
dic : dic.h dic_search.cpp
qt : dic_tools_widget.cpp
utils : eliottxt.cpp
Log message:
Little hack to have the 7+1 search in alphabetical order (or more
precisely, in the order of the letters as defined at dictionary creation)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic.h?cvsroot=eliot&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic_search.cpp?cvsroot=eliot&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/dic_tools_widget.cpp?cvsroot=eliot&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/eliottxt.cpp?cvsroot=eliot&r1=1.38&r2=1.39
Patches:
Index: dic/dic.h
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- dic/dic.h 3 Jul 2009 21:40:15 -0000 1.25
+++ dic/dic.h 21 Sep 2009 20:10:34 -0000 1.26
@@ -232,13 +232,18 @@
/**
* Search for all feasible word with "rack" plus one letter
+ * XXX: the key in the map is the internal code, because it allows an easy
+ * iteration in the map in the order of the dictionary letters.
+ * Maybe a more powerful structure should be provided, to hide the internal
+ * chars to the caller.
+ *
* @param iRack: letters
- * @param oWordlist: results (grouped by added character)
+ * @param oWordlist: results (grouped by code of the added character)
* @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<wstring, vector<wdstring> > &oWordList,
+ map<unsigned int, vector<wdstring> > &oWordList,
bool joker) const;
/**
Index: dic/dic_search.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic_search.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- dic/dic_search.cpp 3 Jul 2009 21:40:15 -0000 1.17
+++ dic/dic_search.cpp 21 Sep 2009 20:10:34 -0000 1.18
@@ -76,9 +76,9 @@
struct params_7plus1_t
{
- wchar_t added_code;
+ unsigned int added_code;
wdstring added_display;
- map<wdstring, vector<wdstring> > *results;
+ map<unsigned int, vector<wdstring> > *results;
int search_len;
wchar_t search_wordtst[DIC_WORD_MAX];
char search_letters[63];
@@ -103,7 +103,7 @@
if (edgeptr->term)
{
// Add the solution
- vector<wdstring> &sols =
(*params.results)[params.added_display];
+ vector<wdstring> &sols =
(*params.results)[params.added_code];
if (sols.empty() || sols.back() !=
params.search_wordtst)
sols.push_back(convertToDisplay(params.search_wordtst));
}
@@ -126,7 +126,7 @@
if (edgeptr->term)
{
// Add the solution
- vector<wdstring> &sols =
(*params.results)[params.added_display];
+ vector<wdstring> &sols =
(*params.results)[params.added_code];
if (sols.empty() || sols.back() !=
params.search_wordtst)
sols.push_back(convertToDisplay(params.search_wordtst));
}
@@ -144,7 +144,7 @@
void Dictionary::search7pl1(const wstring &iRack,
- map<wdstring, vector<wdstring> > &oWordList,
+ map<unsigned int, vector<wdstring> > &oWordList,
bool joker) const
{
if (iRack == L"" || iRack.size() > DIC_WORD_MAX)
@@ -407,7 +407,6 @@
unsigned int iMaxLength,
unsigned int iMaxResults) const
{
- // XXX: throw an exception?
if (iRegexp == L"")
return true;
Index: qt/dic_tools_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/dic_tools_widget.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- qt/dic_tools_widget.cpp 3 Jul 2009 21:40:15 -0000 1.12
+++ qt/dic_tools_widget.cpp 21 Sep 2009 20:10:34 -0000 1.13
@@ -200,18 +200,18 @@
if (input != L"")
{
- map<wstring, vector<wstring> > wordList;
+ map<unsigned int, vector<wstring> > wordList;
m_dic->search7pl1(input, wordList, true);
int rowNum = 0;
- map<wstring, vector<wstring> >::const_iterator it;
+ map<unsigned int, vector<wstring> >::const_iterator it;
for (it = wordList.begin(); it != wordList.end(); it++)
{
// Create the header line
model->insertRow(rowNum);
const QModelIndex &index = model->index(rowNum, 0);
- if (it->first != L"")
- model->setData(index, qfw(it->first));
+ if (it->first != 0)
+ model->setData(index,
qfw(m_dic->getHeader().getDisplayStr(it->first)));
else
model->setData(index, _q("Anagrams"));
treeView->setExpanded(index, true);
Index: utils/eliottxt.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/eliottxt.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- utils/eliottxt.cpp 3 Jul 2009 21:40:16 -0000 1.38
+++ utils/eliottxt.cpp 21 Sep 2009 20:10:34 -0000 1.39
@@ -38,6 +38,7 @@
#endif
#include "dic.h"
+#include "header.h"
#include "dic_exception.h"
#include "game_io.h"
#include "game_factory.h"
@@ -601,13 +602,13 @@
break;
case L'p':
{
- map<wdstring, vector<wdstring> >
wordMap;
+ map<unsigned int, vector<wdstring>
> wordMap;
iGame.getDic().search7pl1(word,
wordMap, false);
- map<wdstring, vector<wdstring>
>::const_iterator it;
+ map<unsigned int, vector<wdstring>
>::const_iterator it;
for (it = wordMap.begin(); it !=
wordMap.end(); ++it)
{
- if (it->first != L"")
- cout << "+" <<
convertToMb(it->first) << endl;
+ if (it->first != 0)
+ cout << "+" <<
convertToMb(iGame.getDic().getHeader().getDisplayStr(it->first)) << endl;
BOOST_FOREACH(const wdstring
&wstr, it->second)
{
cout << " " <<
convertToMb(wstr) << endl;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot dic/dic.h dic/dic_search.cpp qt/dic_tools...,
Olivier Teulière <=