sclass QuadTreeBitMatrix > WidthAndHeightImpl { sclass Node {} sclass Prim > Node {} sclass On > Prim {} static new On on; sclass Off > Prim {} static new Off off; sclass Composite > Node { Node a, b, c, d; } Node root = off; *() {} *(int *width, int *height) {} int half(int x) { ret roundUpToPowerOfTwo((x+1)/2); } int halfX(Rect r) { ret r.x+half(r.w); } int halfY(Rect r) { ret r.y+half(r.h); } Rect rectA(Rect r) { ret rect(r.x, r.y, half(r.w), half(r.h)); } Rect rectB(Rect r) { ret rectFromPoints(r.x+half(r.w), r.y, r.x2(), r.y2()); } Rect rectC(Rect r) { ret rectFromPoints(r.x, r.y+half(r.h), r.x+half(r.w), r.y2()); } Rect rectD(Rect r) { ret rectFromPoints(r.x+half(r.w), r.y+half(r.h), r.x2(), r.y2()); } bool get(int x, int y) { Node node = root; Rect r = rect(0, 0, width, height); if (node instanceof Prim) ret node == on; } }