Libsaki
Core library of Pancake Mahjong
tile_count_list.h
1 #ifndef SAKI_TILE_COUNT_LIST_H
2 #define SAKI_TILE_COUNT_LIST_H
3 
4 #include "tile_count.h"
5 
6 
7 
8 namespace saki
9 {
10 
11 
12 
18 {
19 public:
20  struct End {};
21 
22  class Iter
23  {
24  public:
25  explicit Iter(int sum, T34 min, T34 max);
26 
27  // std input iterator traits
28  using iterator_category = std::input_iterator_tag;
29  using difference_type = int;
30  using value_type = const TileCount &;
31  using pointer = const TileCount *;
32  using reference = const TileCount &;
33 
34  const TileCount &operator*() noexcept;
35  Iter &operator++() noexcept;
36  bool operator==(End that) const noexcept;
37  bool operator!=(End that) const noexcept;
38 
39  private:
40  bool isMax(int beginIndex, int task) const;
41  void setMin(int begin, int task);
42 
43  private:
44  int mSum;
45  T34 mMinTile;
46  T34 mMaxTile;
47  TileCount mCount;
48  bool mEnd = false;
49  };
50 
51  explicit TileCountList(int sum, T34 min = T34(0), T34 max = T34(33));
52 
53  Iter begin();
54  End end();
55 
56 private:
57  int mSum;
58  T34 mMinTile;
59  T34 mMaxTile;
60 };
61 
62 
63 
64 } // namespace saki
65 
66 
67 
68 #endif // SAKI_TILE_COUNT_LIST_H
An iterable virtual list of all tile-counts whose containing tiles sum up to a given number...
Definition: tile_count_list.h:17
TileCountList(int sum, T34 min=T34(0), T34 max=T34(33))
Contruct a virtual list of hands formed by tiles in range [min, max].
Definition: tile_count_list.cpp:16
Definition: tile.h:25
Definition: tile_count.h:17
Definition: ai.cpp:18
Definition: tile_count_list.h:20
Definition: tile_count_list.h:22