Dictionary type changed from std::map to std::multimap. But need to improve this

This commit is contained in:
2015-07-16 23:34:43 +03:00
parent 8d5b9bfc95
commit 7825985f1d
5 changed files with 12 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Project Name="CrossBench" InternalType="GUI"> <CodeLite_Project Name="CrossBench" InternalType="GUI">
<Plugins> <Plugins>
<Plugin Name="CppCheck"/>
<Plugin Name="CMakePlugin"> <Plugin Name="CMakePlugin">
<![CDATA[[{ <![CDATA[[{
"name": "Debug", "name": "Debug",
@@ -31,7 +32,6 @@
"parentProject": "" "parentProject": ""
}]]]> }]]]>
</Plugin> </Plugin>
<Plugin Name="CppCheck"/>
</Plugins> </Plugins>
<Description/> <Description/>
<Dependencies/> <Dependencies/>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="CrossGen" Database=""> <CodeLite_Workspace Name="CrossGen" Database="">
<Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="No"/> <Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="Yes"/>
<Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="Yes"/> <Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="No"/>
<Environment> <Environment>
<![CDATA[]]> <![CDATA[]]>
</Environment> </Environment>
@@ -12,7 +12,7 @@
</WorkspaceConfiguration> </WorkspaceConfiguration>
<WorkspaceConfiguration Name="Release" Selected="yes"> <WorkspaceConfiguration Name="Release" Selected="yes">
<Project Name="wxCrossGen" ConfigName="Release"/> <Project Name="wxCrossGen" ConfigName="Release"/>
<Project Name="CrossBench" ConfigName="Profiling"/> <Project Name="CrossBench" ConfigName="Release"/>
</WorkspaceConfiguration> </WorkspaceConfiguration>
</BuildMatrix> </BuildMatrix>
</CodeLite_Workspace> </CodeLite_Workspace>

View File

@@ -6,7 +6,9 @@
#include <cstdint> #include <cstdint>
#include <map> #include <map>
typedef std::map< wxString, wxString > DictType; // TODO: Improve worling with multiple definition of words. Move working with it
// to crossgen.cpp from fmain.cpp
typedef std::multimap< wxString, wxString > DictType;
typedef std::vector< std::vector< wxChar > > GridType; typedef std::vector< std::vector< wxChar > > GridType;
typedef uint8_t TransedChar; typedef uint8_t TransedChar;

View File

@@ -14,7 +14,7 @@ void readDict(const wxString &path, DictType &dict_out){
int del_ind = str.Index('-'); int del_ind = str.Index('-');
wxString key = str.Left(del_ind-1); wxString key = str.Left(del_ind-1);
wxString val = str.Right(str.size() - del_ind - 2); wxString val = str.Right(str.size() - del_ind - 2);
dict_out[key] = val; dict_out.insert(std::make_pair(key,val));
} }
f.Close(); f.Close();
}; };
@@ -304,7 +304,7 @@ bool procCross(
t_grid[cur_wi.x][j + cur_wi.y] = cur_word[j]; t_grid[cur_wi.x][j + cur_wi.y] = cur_word[j];
} }
if (procCross(t_used, words, t_grid, winfos, cur_word_ind + 1, out)){ if ( procCross(t_used, words, t_grid, winfos, cur_word_ind + 1, out) ){
out.push_back(cur_word); out.push_back(cur_word);
return true; return true;
} }
@@ -318,9 +318,9 @@ void generateCross(const GridType &grid, const AllWordsType &words,
std::vector<WordInfo> winfos; std::vector<WordInfo> winfos;
generateWordInfo(grid, winfos); generateWordInfo(grid, winfos);
for (size_t i = 0; i < winfos.size(); ++i) for (auto el: winfos)
wxLogDebug(wxT("Word at (%2d,%2d) with len = %2d and index = %2d and dir = %d"), wxLogDebug(wxT("Word at (%2d,%2d) with len = %2d and index = %2d and dir = %d"),
winfos.at(i).x,winfos.at(i).y,winfos.at(i).len, winfos.at(i).ind, int(winfos.at(i).direct)); el.x,el.y,el.len, el.ind, int(el.direct));
WorkGridType grid_work; WorkGridType grid_work;
toWorkGridType(grid, grid_work); toWorkGridType(grid, grid_work);

View File

@@ -142,7 +142,7 @@ void MainFrame::onGenerateClick(wxCommandEvent &event) {
_ques.clear(); _ques.clear();
for (size_t i = 0; i < words_out.size(); ++i) for (size_t i = 0; i < words_out.size(); ++i)
_ques.push_back(_dict[words_out.at(i)]); _ques.push_back(_dict.find(words_out.at(i))->second);
tOutput->Clear(); tOutput->Clear();