1     namespace NKlein_54321 {
2             class Cube {
3                     public:
4                             typedef int CellType;
5                             enum { SIDE_LENGTH = 4 };
6                             enum { DIMENSIONS = 4 };
7                             enum {
8                                 ARRAY_LEN = SIDE_LENGTH * SIDE_LENGTH * SIDE_LENGTH * SIDE_LENGTH
9                             };
10                     public:
11                             Cube( void );
12                     public:
13                             void operator = ( const CellType& value );
14                     public:
15                             static void indexToVector(
16                                     unsigned int index,
17                                     unsigned int vec[ DIMENSIONS ]
18                                 );
19                             static void vectorToIndex(
20                                     const unsigned int vec[ DIMENSIONS ],
21                                     unsigned int* index
22                                 );
23                             static bool determineAxis(
24                                     unsigned int vf[ DIMENSIONS ],
25                                     unsigned int vt[ DIMENSIONS ],
26                                     bool wrapping,
27                                     unsigned int* axis,
28                                     bool* positive
29                                 );
30                     public:
31                             CellType& operator [] ( const unsigned int vec[ DIMENSIONS ] );
32                             CellType& operator [] ( const unsigned int index );
33                             static unsigned int getNeighbors(
34                                     unsigned int nn[ 2 * DIMENSIONS ],
35                                     unsigned int index,
36                                     unsigned int dimensions,
37                                     bool wrap = true
38                                 );
39                     private:
40                             CellType array[ ARRAY_LEN ];
41                     public:
42                             static const unsigned int arrayLengths[];
43             };
44     };
45