Fixed compilation of Board::checkDouble() in debug mode (the == operator was

missing for Cross objects)
This commit is contained in:
Olivier Teulière 2005-04-02 17:59:07 +00:00
parent 8121c6ab4c
commit 383548a799
3 changed files with 37 additions and 13 deletions

View file

@ -3,7 +3,7 @@
* Authors: Antoine Fraboulet <antoine.fraboulet@free.fr>
* Olivier Teuliere <ipkiss@via.ecp.fr>
*
* $Id: board.cpp,v 1.4 2005/03/29 06:58:23 afrab Exp $
* $Id: board.cpp,v 1.5 2005/04/02 17:59:07 ipkiss Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -432,27 +432,27 @@ int Board::getLetterMultiplier(int iRow, int iCol) const
#ifdef DEBUG
void Board::checkDouble()
{
int row, col;
for (row = BOARD_MIN; row <= BOARD_MAX; row++)
for (int row = BOARD_MIN; row <= BOARD_MAX; row++)
{
for (col = BOARD_MIN; col <= BOARD_MAX; col++)
for (int col = BOARD_MIN; col <= BOARD_MAX; col++)
{
/*
does not work, Matrix[][] does not reduce to templace type ?
*/
/*
if (m_tilesRow[row][col] != m_tilesCol[col][row])
printf("tiles diff %d %d\n",row,col);
printf("tiles diff %d %d\n", row, col);
// The crossckecks and the points have no reason to be the same
// in both directions
/*
if (m_crossRow[row][col] != m_crossCol[col][row])
{
printf("cross diff %d %d\n",row,col);
}
if (m_pointRow[row][col] != m_pointCol[col][row])
printf("point diff %d %d\n",row,col);
*/
if (m_jokerRow[row][col] != m_jokerCol[col][row])
printf("joker diff %d %d\n",row,col);
*/
printf("joker diff %d %d\n", row, col);
}
}
printf("**\n");

View file

@ -2,7 +2,7 @@
* Copyright (C) 2005 Eliot
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
*
* $Id: cross.cpp,v 1.1 2005/02/05 11:14:56 ipkiss Exp $
* $Id: cross.cpp,v 1.2 2005/04/02 17:59:07 ipkiss Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -43,3 +43,24 @@ bool Cross::check(const Tile& iTile) const
set<Tile>::const_iterator it = m_tilesSet.find(iTile);
return it != m_tilesSet.end();
}
bool Cross::operator==(const Cross &iOther) const
{
if (isAny() && iOther.isAny())
return true;
// Two sets are equal if they have the same size and one of them contains
// the other one
if (m_tilesSet.size() == iOther.m_tilesSet.size())
{
set<Tile>::const_iterator it;
for (it = m_tilesSet.begin(); it != m_tilesSet.end(); it++)
{
if (!iOther.check(*it))
return false;
}
return true;
}
else
return false;
}

View file

@ -2,7 +2,7 @@
* Copyright (C) 2005 Eliot
* Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
*
* $Id: cross.h,v 1.1 2005/02/05 11:14:56 ipkiss Exp $
* $Id: cross.h,v 1.2 2005/04/02 17:59:07 ipkiss Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -42,6 +42,9 @@ public:
bool isAny() const { return m_any; }
bool check(const Tile& iTile) const;
bool operator==(const Cross &iOther) const;
bool operator!=(const Cross &iOther) const { return !(*this == iOther); }
// Standard set methods (almost)
unsigned int size() const { return m_tilesSet.size(); }
void insert(const Tile& iTile) { m_tilesSet.insert(iTile); }