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:
philippe lhardy
2020-12-27 15:40:22 +01:00
parent e146199ba0
commit afbe26065b
15 changed files with 403 additions and 26 deletions

View File

@@ -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;
}
}
}