int getFlipSym() { if (FlipR2S != null) { return FlipR2S[getFlip()]; } if (temps == null) { temps = new CubieCube(); } for (int k = 0; k < 16; k += 2) { EdgeConjugate(this, SymInv[k], temps); int idx = Util.binarySearch(FlipS2R, temps.getFlip()); if (idx != 0xffff) { return (idx << 3) | (k >> 1); } } return 0; }
static void initFlipSym2Raw() { CubieCube c = new CubieCube(); CubieCube d = new CubieCube(); int[] occ = new int[2048 >> 5]; int count = 0; for (int i = 0; i < 2048 >> 5; occ[i++] = 0) ; FlipR2S = new char[2048]; for (int i = 0; i < 2048; i++) { if ((occ[i >> 5] & (1 << (i & 0x1f))) == 0) { c.setFlip(i); for (int s = 0; s < 16; s += 2) { EdgeConjugate(c, s, d); int idx = d.getFlip(); if (idx == i) { SymStateFlip[count] |= 1 << (s >> 1); } occ[idx >> 5] |= 1 << (idx & 0x1f); FlipR2S[idx] = (char) ((count << 3) | (s >> 1)); } FlipS2R[count++] = (char) i; } } }