diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-11-25 06:44:40 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-11-25 06:44:40 +0100 |
commit | fa8f99cb63cd04bb8006e3f568d7f2494723528f (patch) | |
tree | 4c64aa1766219877f0e382acfef8f819c6e805d6 /common/tile.h | |
parent | 4282a9d069b3bedc8888a4e6202f2b066233d4ec (diff) |
Added Tiles::sort().
Diffstat (limited to 'common/tile.h')
-rw-r--r-- | common/tile.h | 20 |
1 files changed, 17 insertions, 3 deletions
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 <stdint.h> #include <vector> +#include <boost/serialization/base_object.hpp> 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<Tile> Tiles; +//! List of tiles. +class Tiles : public std::vector<Tile> { + public: + //! Sort the list of tiles. + void sort(); + + template<class Archive> + void serialize(Archive & ar, const unsigned int version) { + ar & boost::serialization::base_object<std::vector<Tile> >(*this); + } +}; #endif |