I'm trying to figure out an algorithm that would sort cubic area (ex the area defined by (0, 0, 0) to (1, 1, 1) and would be as fast as possible to return the area when given coordinates.
ex: data structure contains area: (0, 0, 0) to (100, 100, 100), (1000, 1000, 1000) to (1010, 1010, 1010) and (-50, -50, -50) to (60, -60, 60)
thus searching for 10, 10, 10 would return area 1, (1001, 1001, 1001) would return area 2 etc
Sort, add, remove time can be long. I need a fast search time we can assume its only integers that will be searched and the solution of making a 3d grid and filling every cell contained within the area with a reference to the area is NOT an acceptable solution, i don't have 3TB of ram to dedicate to this :P. We can also assume that areas will NOT be overlapping, if that helps anyone
If anybody has an idea I'd be glad to hear it
Thanks guys
-Olivier-
Edit: using a structure that holds minX, minY, minZ, maxX, maxY, maxZ to represent an area and place all those area in a list where you search one by one (by checking if the coordinates is bigger then minX but smaller then maxX, and same for every coordinates ) is still too slow O(N)
at the moment I'm exploring the idea to sort then using a n-ary tree, sort by x, then by y, then by z but i do not know if it will be a good one