squareCompressor.cc Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
squareCompressor.cc
Go to the documentation of this file.
1 /* squareCompressor.cc
2 */
3 #include "osl/squareCompressor.h"
4 #include "osl/square.h"
5 #include <algorithm>
6 namespace osl
7 {
8 CArray<signed char, Square::SIZE> SquareCompressor::positionToIndex;
9
10 class SquareCompressor::Initializer
11 {
12 public:
13 Initializer()
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 {
32 SquareCompressor::Initializer init;
33 } // anonymous namespace
34 }
35
36 /* ------------------------------------------------------------------------- */
37 // ;;; Local Variables:
38 // ;;; mode:c++
39 // ;;; c-basic-offset:2
40 // ;;; End: