views:

295

answers:

3

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?

+3  A: 

Please see this question.

Yuval F
A: 

While inserting the objects .. sort them by the cordinates then use divide and conquer algorithm to search for your nearest possibility

Zuhaib
+1  A: 

You may want to look into Binary Space Partitioning, and similar algorithms (Quadtree comes to mind, along with variations on Plane Sweet Algorithms)

Tony Arkles