I'm writing some of my own data structures, such as binary and quad trees, and kD-trees. Is it possible to write them in such a way that allows for any number of dimensions?
Something like:
KDTree<2, string> twoDTree = new KDTree<2, string>();
twoDTree[3,4] = "X,Y = (3,4)";
KDTree<4, string> fourDTree = new KDTree<4, string>();
fourDTree[0,1,2,3] = "x1,x2,x3,x4 = (0,1,2,3)";
The only solution I have now is to explicitly create each dimension as it's own class:
TwoDTree<string> twoDTree = new TwoDTree<string>();
twoDTree[3,4] = "X,Y = (3,4)";
FourDTree<string> fourDTree = new FourDTree<string>();
fourDTree[0,1,2,3] = "x1,x2,x3,x4 = (0,1,2,3)";
But this copy-pastes a ton of code, which should be able to be reused somehow.