My Project
core
osl
bits
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
"
8
namespace
osl
9
{
10
15
struct
SquareCompressor
16
{
17
private
:
19
static
CArray<signed char, Square::SIZE>
positionToIndex
;
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:
osl::Square
Definition:
basic_type.h:532
basic_type.h
osl::SquareCompressor::Initializer
Definition:
squareCompressor.cc:11
osl::SquareCompressor
Square を [0..81] に圧縮する 0: 駒台,1..81 盤上
Definition:
squareCompressor.h:16
osl::SquareCompressor::positionToIndex
static CArray< signed char, Square::SIZE > positionToIndex
本当はconst にしたいけど初期化が手間なので後回し
Definition:
squareCompressor.h:19
osl::Square::index
unsigned int index() const
Definition:
basic_type.h:572
container.h
osl::SquareCompressor::melt
static Square melt(int index)
Definition:
squareCompressor.h:34
osl::Square::STAND
static const Square STAND()
Definition:
basic_type.h:548
osl::CArray< signed char, Square::SIZE >
osl::SquareCompressor::compress
static int compress(Square pos)
Definition:
squareCompressor.h:24
osl::__attribute__
const PtypeO PTYPEO_EDGE __attribute__((unused))
osl
Definition:
additionalEffect.h:6
Generated by
1.8.20