--- queensgui/src/solutionhash.cpp 2007/07/19 21:34:15 1 +++ queensgui/src/containerhash.cpp 2007/07/20 09:54:09 6 @@ -17,9 +17,10 @@ * 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 +32,15 @@ } -SolutionHash::~SolutionHash() +ContainerHash::~ContainerHash() { + for (int i=0; i1 ) { for (int bucket=0; bucket < m_hashroof; bucket++) { @@ -62,18 +67,10 @@ } } for (int i=0; i< (m_hashroof/2); i++) { - //int base = i*2; int base2 = (m_hashroof/2)+i; - /*if (i!=0) { - solutions[i] = solutions[base]; - } ListIt p = solutions[i]->end(); - solutions[i]->splice(p, *solutions[base+1] ); - */ - - ListIt p = solutions[i]->end(); solutions[i]->splice(p, *solutions[base2]); } m_hashroof /= 2; @@ -88,7 +85,7 @@ -void SolutionHash::uniqueSolutionsWorker(int bucket, int rot,bool mirror) +void ContainerHash::uniqueSolutionsWorker(int bucket, int rot,bool mirror) { int match_count; @@ -101,17 +98,21 @@ if (m_halt) return; match_count = 0; - Solution tmp(*i); + + std::auto_ptr tmp( (*i).get()->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) ) { + for ( ; j!=solutions[bucket]->end();j++) + { + if ( *tmp == *(*j) ) + { solutions[bucket]->erase(j); break; } @@ -119,54 +120,23 @@ } } - -/* BACKUP -void SolutionHash::uniqueSolutionsWorker(int rot,bool mirror) -{ - int match_count; - - unique = true; - if (total == -1) - total = solutions.size(); - - for (ListIt i=solutions.begin(); i != solutions.end(); i++) { - match_count = 0; - Solution tmp(*i); - if (mirror) - tmp.mirror(); - for (int k=0;kpush_back(sol); + solutions[hash]->push_back( boost::shared_ptr(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).get(); }