I have collection of objects. Each object represents a coordinate range (ie, a block). What I want is to find the object near another coordinate in a given direction.
Is there a way to do this without traversing the whole collection all the time?
I have collection of objects. Each object represents a coordinate range (ie, a block). What I want is to find the object near another coordinate in a given direction.
Is there a way to do this without traversing the whole collection all the time?
While inserting the objects .. sort them by the cordinates then use divide and conquer algorithm to search for your nearest possibility
You may want to look into Binary Space Partitioning, and similar algorithms (Quadtree comes to mind, along with variations on Plane Sweet Algorithms)