squareCompressor.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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/square.h"
7 #include "osl/misc/carray.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: