prepare for hexagon display & other models
- display cell as hexagon is Display.mHexagon if set ( not default ) will need a checkbox to set this - various new models preparation...
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package org.artisanlogiciel.games.maze.model;
|
||||
|
||||
/**
|
||||
* store an array booleans in a long
|
||||
*/
|
||||
|
||||
public class BooleanLongSet {
|
||||
|
||||
long[] internal;
|
||||
|
||||
// 62 bits for long, 2 bits reserved
|
||||
int USED_BITS = 62;
|
||||
int width;
|
||||
|
||||
public BooleanLongSet(int width, int USED_BITS)
|
||||
{
|
||||
internal = new long[width];
|
||||
this.width = width;
|
||||
this.USED_BITS = USED_BITS;
|
||||
}
|
||||
|
||||
boolean isSet(int x) {
|
||||
int group = x / USED_BITS;
|
||||
if (group < width) {
|
||||
int pos = x % USED_BITS;
|
||||
long mask = 1 << pos;
|
||||
return (internal[group] & mask) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void set(int x, boolean value)
|
||||
{
|
||||
int group = x / USED_BITS;
|
||||
if (group < width) {
|
||||
int pos = x % USED_BITS;
|
||||
long mask = 1 << pos;
|
||||
internal[group] &= mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user