From 425f4e375659d5624c9e2b3b9567df31fcfd7046 Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Sat, 13 Jun 2015 22:28:07 +0300 Subject: [PATCH] Added generateAllWords function --- CrossGen.workspace | 4 ++-- Makefile | 8 ++++---- src/crossgen.hpp | 18 +++++++++++------- wxCrossGen/wxCrossGen.txt | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CrossGen.workspace b/CrossGen.workspace index 18ecac8..7998249 100644 --- a/CrossGen.workspace +++ b/CrossGen.workspace @@ -1,7 +1,7 @@ - - + + diff --git a/Makefile b/Makefile index 68fba5b..2ec856c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ .PHONY: clean All All: - @echo "----------Building project:[ CrossBench - Release ]----------" - @cd "CrossBench" && $(MAKE) -f "CrossBench.mk" + @echo "----------Building project:[ wxCrossGen - Debug ]----------" + @cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" clean: - @echo "----------Cleaning project:[ CrossBench - Release ]----------" - @cd "CrossBench" && $(MAKE) -f "CrossBench.mk" clean + @echo "----------Cleaning project:[ wxCrossGen - Debug ]----------" + @cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" clean diff --git a/src/crossgen.hpp b/src/crossgen.hpp index 27d4074..c32f640 100644 --- a/src/crossgen.hpp +++ b/src/crossgen.hpp @@ -49,6 +49,15 @@ void readGrid(const wxString path, GridType &grid){ 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 &winfos){ wxLogDebug(wxT("Printing grid: ")); for (size_t i = 0; i < grid.size(); ++i){ @@ -118,7 +127,7 @@ void generateWordInfo(const GridType &grid, std::vector &winfos){ } template -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; } @@ -175,17 +184,12 @@ bool procCross(UsedWords used, AllWordsType &words, CurGridType grid, void generateCross(GridType &grid, const DictType &dict, std::vector &words_out){ AllWordsType words; - for (auto it = dict.begin(); it != dict.end(); ++it){ - if (words.size() <= it->first.size()) - words.resize(it->first.size() + 2); - words.at(it->first.size()).push_back(it->first); - } + generateAllWords(dict, words); std::vector winfos; generateWordInfo(grid, winfos); for (size_t i = 0; i < winfos.size(); ++i) 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)); - UsedWords t_used; procCross(t_used, words, grid, winfos, 0, words_out); std::reverse(words_out.begin(), words_out.end()); diff --git a/wxCrossGen/wxCrossGen.txt b/wxCrossGen/wxCrossGen.txt index b7e8d8a..6716386 100644 --- a/wxCrossGen/wxCrossGen.txt +++ b/wxCrossGen/wxCrossGen.txt @@ -1 +1 @@ -../Release/main.cpp.o +./Debug/main.cpp.o