--- queensgui/src/solutionhash.cpp 2007/07/19 21:34:15 1 +++ queensgui/src/solutionhash.cpp 2007/07/19 23:36:33 3 @@ -17,9 +17,9 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "solutionhash.h" +#include "containerhash.h" -SolutionHash::SolutionHash(GUIUpdate* update) +ContainerHash::ContainerHash(GUIUpdate* update) : SolutionContainer(update) { total = -1; @@ -31,11 +31,11 @@ } -SolutionHash::~SolutionHash() +ContainerHash::~ContainerHash() { } -int SolutionHash::numSolutions() +int ContainerHash::numSolutions() { int size = 0; for (int i=0; i1 ) { for (int bucket=0; bucket < m_hashroof; bucket++) { @@ -88,7 +88,7 @@ -void SolutionHash::uniqueSolutionsWorker(int bucket, int rot,bool mirror) +void ContainerHash::uniqueSolutionsWorker(int bucket, int rot,bool mirror) { int match_count; @@ -101,17 +101,17 @@ if (m_halt) return; match_count = 0; - Solution tmp(*i); + Solution* tmp = (*i)->copy(); if (mirror) - tmp.mirror(); + tmp->mirror(); for (int k=0;krotate90(); //unders�g kun resten af m�ngden, start ved i+1 ListIt j =i; j++; for ( ; j!=solutions[bucket]->end();j++) { - if ( tmp == (*j) ) { + if ( *tmp == *(*j) ) { solutions[bucket]->erase(j); break; } @@ -121,7 +121,7 @@ /* BACKUP -void SolutionHash::uniqueSolutionsWorker(int rot,bool mirror) +void ContainerHash::uniqueSolutionsWorker(int rot,bool mirror) { int match_count; @@ -150,23 +150,22 @@ } */ -void SolutionHash::addSolution(Solution sol) +void ContainerHash::addSolution(Solution* sol) { int hash = m_size % max_size; solutions[hash]->push_back(sol); m_size++; } -Solution SolutionHash::solution(int index) +Solution* ContainerHash::solution(int index) { int count=0; - Solution returndata; - for (ListIt it = solutions[0]->begin(); it != solutions[0]->end(); it++, count++) { + ListIt it; + for (it = solutions[0]->begin(); it != solutions[0]->end(); it++, count++) { if (count == index) { - returndata = *it ; - break; - } + break; + } } - return returndata; + return *it; }