Added generateAllWords function
This commit is contained in:
@@ -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"/>
|
||||||
<BuildMatrix>
|
<BuildMatrix>
|
||||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||||
<Project Name="wxCrossGen" ConfigName="Debug"/>
|
<Project Name="wxCrossGen" ConfigName="Debug"/>
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -1,8 +1,8 @@
|
|||||||
.PHONY: clean All
|
.PHONY: clean All
|
||||||
|
|
||||||
All:
|
All:
|
||||||
@echo "----------Building project:[ CrossBench - Release ]----------"
|
@echo "----------Building project:[ wxCrossGen - Debug ]----------"
|
||||||
@cd "CrossBench" && $(MAKE) -f "CrossBench.mk"
|
@cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk"
|
||||||
clean:
|
clean:
|
||||||
@echo "----------Cleaning project:[ CrossBench - Release ]----------"
|
@echo "----------Cleaning project:[ wxCrossGen - Debug ]----------"
|
||||||
@cd "CrossBench" && $(MAKE) -f "CrossBench.mk" clean
|
@cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" clean
|
||||||
|
|||||||
@@ -49,6 +49,15 @@ void readGrid(const wxString path, GridType &grid){
|
|||||||
f.Close();
|
f.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void generateAllWords(const DictType &dict, AllWordsType &words_out){
|
||||||
|
words_out.clear();
|
||||||
|
for (auto it = dict.begin(); it != dict.end(); ++it){
|
||||||
|
if ( words_out.size() <= it->first.size() )
|
||||||
|
words_out.resize(it->first.size() + 2);
|
||||||
|
words_out.at(it->first.size()).push_back(it->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void generateWordInfo(const GridType &grid, std::vector<WordInfo> &winfos){
|
void generateWordInfo(const GridType &grid, std::vector<WordInfo> &winfos){
|
||||||
wxLogDebug(wxT("Printing grid: "));
|
wxLogDebug(wxT("Printing grid: "));
|
||||||
for (size_t i = 0; i < grid.size(); ++i){
|
for (size_t i = 0; i < grid.size(); ++i){
|
||||||
@@ -118,7 +127,7 @@ void generateWordInfo(const GridType &grid, std::vector<WordInfo> &winfos){
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
uint32_t getWordUniq(const T w_ind, const T w_len){
|
uint32_t getWordUniq(const T &w_ind, const T &w_len){
|
||||||
return w_ind + w_len * MAX_WORD_COUNT;
|
return w_ind + w_len * MAX_WORD_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,17 +184,12 @@ bool procCross(UsedWords used, AllWordsType &words, CurGridType grid,
|
|||||||
|
|
||||||
void generateCross(GridType &grid, const DictType &dict, std::vector<wxString> &words_out){
|
void generateCross(GridType &grid, const DictType &dict, std::vector<wxString> &words_out){
|
||||||
AllWordsType words;
|
AllWordsType words;
|
||||||
for (auto it = dict.begin(); it != dict.end(); ++it){
|
generateAllWords(dict, words);
|
||||||
if (words.size() <= it->first.size())
|
|
||||||
words.resize(it->first.size() + 2);
|
|
||||||
words.at(it->first.size()).push_back(it->first);
|
|
||||||
}
|
|
||||||
std::vector<WordInfo> winfos;
|
std::vector<WordInfo> winfos;
|
||||||
generateWordInfo(grid, winfos);
|
generateWordInfo(grid, winfos);
|
||||||
for (size_t i = 0; i < winfos.size(); ++i)
|
for (size_t i = 0; i < winfos.size(); ++i)
|
||||||
wxLogDebug(wxT("Word at (%d,%d) with len = %d and index = %d and dir = %d"),
|
wxLogDebug(wxT("Word at (%d,%d) with len = %d and index = %d and dir = %d"),
|
||||||
winfos.at(i).x,winfos.at(i).y,winfos.at(i).len, winfos.at(i).ind, int(winfos.at(i).direct));
|
winfos.at(i).x,winfos.at(i).y,winfos.at(i).len, winfos.at(i).ind, int(winfos.at(i).direct));
|
||||||
|
|
||||||
UsedWords t_used;
|
UsedWords t_used;
|
||||||
procCross(t_used, words, grid, winfos, 0, words_out);
|
procCross(t_used, words, grid, winfos, 0, words_out);
|
||||||
std::reverse(words_out.begin(), words_out.end());
|
std::reverse(words_out.begin(), words_out.end());
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
../Release/main.cpp.o
|
./Debug/main.cpp.o
|
||||||
|
|||||||
Reference in New Issue
Block a user