/** * Given the zones resulting from this class' calculate method and a Coord to check, finds the indices of all * influencing groups in zones that have the Coord in their area, and returns all such indices as an int array. * @param zones a short[][] returned by calculate; not a multi-packed short[][] from CoordPacker ! * @param point the Coord to test * @return an int[] where each element is the index of an influencing group in zones */ public int[] nearestInfluences(short[][] zones, Coord point) { ShortVLA found = new ShortVLA(4); for (short i = 0; i < zones.length; i++) { if(CoordPacker.queryPacked(zones[i], point.x, point.y)) found.add(i); } return found.asInts(); }
/** * Given the zones resulting from this class' calculate method and a Coord to check, finds the indices of all * influencing groups in zones that have the Coord in their area, and returns all such indices as an int array. * @param zones a short[][] returned by calculate; not a multi-packed short[][] from CoordPacker ! * @param point the Coord to test * @return an int[] where each element is the index of an influencing group in zones */ public int[] nearestInfluences(short[][] zones, Coord point) { ShortVLA found = new ShortVLA(4); for (short i = 0; i < zones.length; i++) { if(CoordPacker.queryPacked(zones[i], point.x, point.y)) found.add(i); } return found.asInts(); } /**
/** * This can be given a Coord to check in the results of the latest calculate() call. Finds the indices of all * influencing groups in zones that have the Coord in their area, and returns all such indices as an int array. * @param point the Coord to test * @return an int[] where each element is the index of an influencing group in zones */ public int[] nearestInfluences(Coord point) { if(!completed) return new int[0]; ShortVLA found = new ShortVLA(4); for (short i = 0; i < packedGroups.length; i++) { if(CoordPacker.queryPacked(packedGroups[i], point.x, point.y)) found.add(i); } return found.asInts(); }
/** * Gets all positions that are "on" in the given packed array, without unpacking it, and returns them as a Coord[]. * @param packed a short[] returned by pack() or one of the sub-arrays in what is returned by packMulti(); must * not be null (this method does not check due to very tight performance constraints). * @return a Coord[], ordered by distance along the Hilbert Curve, corresponding to all "on" cells in packed. */ public static Coord[] allPacked(short[] packed) { ShortVLA vla = new ShortVLA(64); boolean on = false; int idx = 0; for(int p = 0; p < packed.length; p++, on = !on) { if (on) { vla.addRange(idx, idx + (packed[p] & 0xffff)); } idx += packed[p] & 0xffff; } int[] distances = vla.asInts(); Coord[] cs = new Coord[distances.length]; for (int i = 0; i < distances.length; i++) { cs[i] = Coord.get(hilbertX[distances[i]], hilbertY[distances[i]]); } return cs; }
int[] distances = vla.asInts(); Coord[] cs = new Coord[distances.length]; for (int i = 0; i < distances.length; i++) {
int[] distances = vla.asInts(); Coord[] cs = new Coord[distances.length]; for (int i = 0; i < distances.length; i++) {
int[] distances = vla.asInts(); Coord[] cs = new Coord[distances.length]; for (int i = 0; i < distances.length; i++) {
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;
int[] indices = vla.asInts(); if(indices.length < 1)
int[] distances = vla.asInts(); Coord[] cs = new Coord[distances.length]; for (int i = 0; i < distances.length; i++) {
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;
int[] distances = vla.asInts(); Coord[] cs = new Coord[distances.length]; for (int i = 0; i < distances.length; i++) {
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;
int[] indices = vla.asInts(); if(indices.length < 1) return ALL_WALL;