00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SHYPERCUBEPOSITION_H
00029 #define SHYPERCUBEPOSITION_H
00030
00031
00032
00033
00034 #include "SComplexPosition.h"
00035 #include "SDimArray.h"
00036
00037
00038
00039 class SHypercubePosition: public SComplexPosition, public SDimArray {
00040 public:
00041 SHypercubePosition(int dim) : SDimArray(dim) {};
00042
00043
00044 virtual int getMinPos() const {
00045 int linearPos = 0;
00046 for (int i=size()-1; i>=0; i--) {
00047 linearPos *= 2;
00048 if ((*this)[i] == 1)
00049 linearPos += 1;
00050 }
00051 return linearPos;
00052 };
00053
00054 int getMaxPos() const {
00055 int linearPos = 0;
00056 for (int i=size()-1; i>=0; i--) {
00057 linearPos *= 2;
00058 if ((*this)[i] != 0)
00059 linearPos += 1;
00060 }
00061 return linearPos;
00062 };
00063
00064 bool isNormal() const {
00065 int i=0;
00066 while ( (i<size()) && ((*this)[i] == -1) ) i++;
00067 while ( i<size() )
00068 if ( (*this)[i] == -1 )
00069 return false;
00070 else
00071 i++;
00072 return true;
00073 }
00074
00075 };
00076
00077 #endif //SHYPERCUBEPOSITION_H