From fa8f99cb63cd04bb8006e3f568d7f2494723528f Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 25 Nov 2010 06:44:40 +0100 Subject: Added Tiles::sort(). --- common/tile.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'common/tile.h') diff --git a/common/tile.h b/common/tile.h index 93bdb8d..84552aa 100644 --- a/common/tile.h +++ b/common/tile.h @@ -3,6 +3,7 @@ #include #include +#include class Tile { public: @@ -60,10 +61,13 @@ class Tile { virtual ~Tile(){}; //! Get the numeric value of the tile (if one of the man/pin/sou-sets). - int get_num(); + int get_num() const; //! Compare two tiles. Equal if type matches; flags are not compared. - bool operator==(const Tile& other); + bool operator==(const Tile& other) const; + + //! Compare two tiles. Ordered by type, red < non-red. + bool operator<(const Tile& other) const; //! Increment type. Useful for iterating over all possible types. Tile operator++(int); @@ -76,6 +80,16 @@ class Tile { } }; -typedef std::vector Tiles; +//! List of tiles. +class Tiles : public std::vector { + public: + //! Sort the list of tiles. + void sort(); + + template + void serialize(Archive & ar, const unsigned int version) { + ar & boost::serialization::base_object >(*this); + } +}; #endif -- cgit v1.2.3