From 383548a799b3b8022eb666b97f48a8282aa185d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Sat, 2 Apr 2005 17:59:07 +0000 Subject: [PATCH] Fixed compilation of Board::checkDouble() in debug mode (the == operator was missing for Cross objects) --- game/board.cpp | 22 +++++++++++----------- game/cross.cpp | 23 ++++++++++++++++++++++- game/cross.h | 5 ++++- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/game/board.cpp b/game/board.cpp index 7ca1d43..b2cff55 100644 --- a/game/board.cpp +++ b/game/board.cpp @@ -3,7 +3,7 @@ * Authors: Antoine Fraboulet * Olivier Teuliere * - * $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"); diff --git a/game/cross.cpp b/game/cross.cpp index 401d770..bf0c262 100644 --- a/game/cross.cpp +++ b/game/cross.cpp @@ -2,7 +2,7 @@ * Copyright (C) 2005 Eliot * Authors: Olivier Teuliere * - * $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::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::const_iterator it; + for (it = m_tilesSet.begin(); it != m_tilesSet.end(); it++) + { + if (!iOther.check(*it)) + return false; + } + return true; + } + else + return false; +} diff --git a/game/cross.h b/game/cross.h index f177105..451e04a 100644 --- a/game/cross.h +++ b/game/cross.h @@ -2,7 +2,7 @@ * Copyright (C) 2005 Eliot * Authors: Olivier Teuliere * - * $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); }