i working 16x16x16 cube of information, @ each position need store pair(int,int). in use cases majority of cube holding (0,0), there potential every position hold unique information.
it might worth noting relation between information being held in pair(int,int) in same position.
- the first value 0-9 can value
- represents attribute of position.
- the second value represents pattern 0-6 or combination of 1-6 in ascending order(eg 12, 123456)
- it describes relation between current position , 6 adjacent positions.
- the second value can technically 0-64 sanity while working have used pattern.
i using 3d array seems such large waste considering majority of array holds same (0,0) value. should mention not access information outside of saving , during setup.
if has suggestion better storage structure appreciate input.
the first that came mind defining own classes cube, pair, , 3-tuple, following:
public class inttuple { private final int x; private final int y; private final int z; public tuple(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } public int getx() { return x; } public int gety() { return y; } public int getz() { return z; } } and similar class pair. cube can like:
public class cube { private hashmap<inttuple, intpair> cubemap = new hashmap<inttuple, intpair>(); private zeropair = new intpair(0, 0); public addpair(inttuple coords, intpair pair) { cubemap.put(coords, pair); } public intpair getpair(inttuple coords) { if (cubemap.containskey(coords)) return cubemap.get(coords); else return zeropair; } } in terms of storage reduce overhead store coordinates non-zero pairs, , have fast access hashmap. 1 0 pair created , return 1 reference.
if wanted little greater scalability, make 3 classes generic types re-use structures storing objects other integers.
Comments
Post a Comment