squareCompressor.cc
Go to the documentation of this file.
1 /* squareCompressor.cc
2  */
4 #include "osl/basic_type.h"
5 #include <algorithm>
6 namespace osl
7 {
8  CArray<signed char, Square::SIZE> SquareCompressor::positionToIndex;
9 
11  {
12  public:
14  {
15  std::fill(positionToIndex.begin(), positionToIndex.end(), -1);
16 
17  int cur = 0;
18  positionToIndex[0] = cur++;
19  for (int x=1; x<=9; ++x)
20  {
21  for (int y=1; y<=9; ++y)
22  {
23  positionToIndex[Square(x,y).index()] = cur++;
24  }
25  }
26  assert(cur == 82);
27  }
28  };
29 
30  namespace
31  {
33  } // anonymous namespace
34 }
35 
36 /* ------------------------------------------------------------------------- */
37 // ;;; Local Variables:
38 // ;;; mode:c++
39 // ;;; c-basic-offset:2
40 // ;;; End:
iterator begin()
Definition: container.h:64
unsigned int index() const
Definition: basic_type.h:572
iterator end()
Definition: container.h:65
static CArray< signed char, Square::SIZE > positionToIndex
本当はconst にしたいけど初期化が手間なので後回し