- since we use History, the first round is numbered 1

- separate sort_by_points method, removed call from board_search
This commit is contained in:
Antoine Fraboulet 2005-12-26 21:22:21 +00:00
parent 1fb948cba9
commit 3bde5c3da5
3 changed files with 40 additions and 5 deletions

View file

@ -269,7 +269,6 @@ void Board::search(const Dictionary &iDic,
BoardSearchAux(*this, iDic, m_tilesCol, m_crossCol,
m_pointCol, m_jokerCol,
copyRack, oResults, Coord::VERTICAL);
oResults.sort();
}
@ -290,5 +289,4 @@ void Board::searchFirst(const Dictionary &iDic,
m_pointRow, m_jokerRow,
copyRack, partialword, oResults, Dic_root(iDic), row, col,
copyRack.nTiles() - 1);
oResults.sort();
}

View file

@ -18,6 +18,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/**
* \file results.cc
* \brief Search result storage class
* \author Olivier Teulière & Antoine Fraboulet
* \date 2005
*/
#include <algorithm>
#include <functional>
@ -51,17 +58,31 @@ void Results::search(const Dictionary &iDic, Board &iBoard,
{
clear();
if (iTurn == 0)
/* we start at round 1 */
if (iTurn == 1)
{
iBoard.searchFirst(iDic, iRack, *this);
}
else
{
iBoard.search(iDic, iRack, *this);
}
sort_by_points();
}
void Results::sort()
void Results::sort_by_points()
{
less_points lp;
std::sort(m_rounds.begin(), m_rounds.end(), lp);
}
/****************************************************************/
/****************************************************************/
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// End:

View file

@ -18,6 +18,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
/**
* \file results.h
* \brief Search result storage class
* \author Olivier Teulière & Antoine Fraboulet
* \date 2005
*/
#ifndef _RESULTS_H_
#define _RESULTS_H_
@ -53,11 +60,20 @@ public:
// FIXME: These methods are used to fill the container with the rounds,
// but they should not be part of the public interface
void sort();
void add(const Round &iRound) { m_rounds.push_back(iRound); }
void sort_by_points();
private:
vector<Round> m_rounds;
};
#endif
/****************************************************************/
/****************************************************************/
/// Local Variables:
/// mode: c++
/// mode: hs-minor
/// c-basic-offset: 4
/// End: