Some code improvements, many "const" added

This commit is contained in:
2015-06-11 22:58:58 +03:00
parent a6ddedd5be
commit 34beee9850
2 changed files with 6 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
#include <cstdint> #include <cstdint>
#include <map> #include <map>
typedef std::map<wxString,wxString> DictType; typedef std::map< wxString, wxString > DictType;
typedef std::vector< std::vector<wxChar> > GridType; typedef std::vector< std::vector<wxChar> > GridType;
typedef std::vector< std::vector<wxChar> > CurGridType; typedef std::vector< std::vector<wxChar> > CurGridType;
// Fisrt index is a word length // Fisrt index is a word length

View File

@@ -11,7 +11,7 @@
const wxChar CELL_CLEAR = wxT('+'); const wxChar CELL_CLEAR = wxT('+');
const uint32_t MAX_WORD_COUNT = 262144; // =2^18 const uint32_t MAX_WORD_COUNT = 262144; // =2^18
void readDict(wxString path, DictType &dict){ void readDict(const wxString path, DictType &dict){
wxTextFile f; wxTextFile f;
f.Open(path); f.Open(path);
for ( wxString str = f.GetFirstLine(); !f.Eof(); str = f.GetNextLine() ) { for ( wxString str = f.GetFirstLine(); !f.Eof(); str = f.GetNextLine() ) {
@@ -26,7 +26,7 @@ void readDict(wxString path, DictType &dict){
f.Close(); f.Close();
}; };
void readGrid(wxString path, GridType &grid){ void readGrid(const wxString path, GridType &grid){
wxTextFile f; wxTextFile f;
f.Open(path); f.Open(path);
wxString str = f.GetFirstLine(); wxString str = f.GetFirstLine();
@@ -48,7 +48,7 @@ void readGrid(wxString path, GridType &grid){
f.Close(); f.Close();
} }
void generateWordInfo(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){
wxString st; wxString st;
@@ -117,7 +117,7 @@ void generateWordInfo(GridType &grid, std::vector<WordInfo> &winfos){
} }
template <class T> template <class T>
uint32_t getWordUniq(T w_ind, 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;
} }
@@ -173,7 +173,7 @@ bool procCross(UsedWords used, AllWordsType &words, CurGridType grid,
return false; return false;
} }
void generateCross(GridType &grid, DictType &dict, std::vector<wxString> &words_out){ void generateCross(GridType &grid, const DictType &dict, std::vector<wxString> &words_out){
AllWordsType words; AllWordsType words;
for (DictType::iterator it = dict.begin(); it != dict.end(); ++it){ for (DictType::iterator it = dict.begin(); it != dict.end(); ++it){
if (words.size() <= it->first.size()) if (words.size() <= it->first.size())