My Project
squareCompressor.h
Go to the documentation of this file.
1/* squareCompressor.h
2 */
3#ifndef OSL_POSITIONCOMPRESSOR_H
4#define OSL_POSITIONCOMPRESSOR_H
5
6#include "osl/basic_type.h"
7#include "osl/container.h"
8namespace osl
9{
10
16 {
17 private:
20 public:
21 class Initializer;
22 friend class Initializer;
23
24 static int compress(Square pos)
25 {
26 const int result = positionToIndex[pos.index()];
27 assert(result >= 0);
28 return result;
29 }
30 static Square
31#ifdef __GNUC__
32__attribute__ ((noinline))
33#endif
34 melt(int index)
35 {
36 assert(0 <= index);
37 assert(index < 82);
38 if (index == 0)
39 return Square::STAND();
40 --index;
41 return Square(index/9+1, index%9+1);
42 }
43 };
44
45} // namespace osl
46
47#endif /* OSL_POSITIONCOMPRESSOR_H */
48// ;;; Local Variables:
49// ;;; mode:c++
50// ;;; c-basic-offset:2
51// ;;; End:
unsigned int index() const
Definition basic_type.h:572
static const Square STAND()
Definition basic_type.h:548
const PtypeO PTYPEO_EDGE __attribute__((unused))
Square を [0..81] に圧縮する 0: 駒台,1..81 盤上
static int compress(Square pos)
static CArray< signed char, Square::SIZE > positionToIndex
本当はconst にしたいけど初期化が手間なので後回し
static Square melt(int index)