squareCompressor.h
Go to the documentation of this file.
/* squareCompressor.h
*/
#ifndef OSL_POSITIONCOMPRESSOR_H
#define OSL_POSITIONCOMPRESSOR_H
#include "osl/basic_type.h"
#include "osl/container.h"
namespace osl
{
struct SquareCompressor
{
private:
static CArray<signed char, Square::SIZE> positionToIndex;
public:
class Initializer;
friend class Initializer;
static int compress(Square pos)
{
const int result = positionToIndex[pos.index()];
assert(result >= 0);
return result;
}
static Square
#ifdef __GNUC__
__attribute__ ((noinline))
#endif
melt(int index)
{
assert(0 <= index);
assert(index < 82);
if (index == 0)
return Square::STAND();
--index;
return Square(index/9+1, index%9+1);
}
};
} // namespace osl
#endif /* OSL_POSITIONCOMPRESSOR_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
basic_type.h
osl::CArray
Definition container.h:20
osl::SquareCompressor::Initializer
Definition squareCompressor.cc:11
osl::Square
Definition basic_type.h:532
osl::Square::index
unsigned int index() const
Definition basic_type.h:572
osl::Square::STAND
static const Square STAND()
Definition basic_type.h:548
container.h
osl
Definition additionalEffect.h:6
osl::__attribute__
const PtypeO PTYPEO_EDGE __attribute__((unused))
osl::SquareCompressor
Square を [0..81] に圧縮する 0: 駒台，1..81 盤上
Definition squareCompressor.h:16
osl::SquareCompressor::compress
static int compress(Square pos)
Definition squareCompressor.h:24
osl::SquareCompressor::positionToIndex
static CArray< signed char, Square::SIZE > positionToIndex
本当はconst にしたいけど初期化が手間なので後回し
Definition squareCompressor.h:19
osl::SquareCompressor::melt
static Square melt(int index)
Definition squareCompressor.h:34