File: squareCompressor.cc

package info (click to toggle)
libosl 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 273,976 kB
  • sloc: cpp: 129,625; ansic: 7,145; ruby: 1,290; makefile: 558; perl: 413; sh: 35
file content (40 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* squareCompressor.cc
 */
#include "osl/squareCompressor.h"
#include "osl/square.h"
#include <algorithm>
namespace osl
{
  CArray<signed char, Square::SIZE> SquareCompressor::positionToIndex;

  class SquareCompressor::Initializer
  {
  public:
    Initializer()
    {
      std::fill(positionToIndex.begin(), positionToIndex.end(), -1);

      int cur = 0;
      positionToIndex[0] = cur++;
      for (int x=1; x<=9; ++x)
      {
	for (int y=1; y<=9; ++y)
	{
	  positionToIndex[Square(x,y).index()] = cur++;
	}
      }
      assert(cur == 82);
    }
  };
    
  namespace 
  {
    SquareCompressor::Initializer init;
  } // anonymous namespace
}

/* ------------------------------------------------------------------------- */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End: