Data structure for ordered sequence

robert no-spam at no-spam-no-spam.invalid
Thu Nov 16 10:40:18 CET 2006


jm.suresh at no.spam.gmail.com wrote:
> Fredrik Lundh wrote:
>> jm.suresh at no.spam.gmail.com wrote:
>>
>>>  I am looking for a data structure to hold rectangles in a 2d space.
>>> Please point me to any module which does these operations:
>>>  Insert a rectangle into a particular co-ordinate.
>>>  Get the rectangle/s right/left/above/below side to a particular
>>> rectangle.
>>>  Get all the rectangles within a box
>>>  Delete a particular rectangle.
>> how many rectangles do you plan to store in this structure?
>>
>> </F>
> 
> Around 150 max
> 

And seeking/change frequency? fix dimensions? Probably for a GUI/mouse thing. 
=>Not worth worring about a 2D-tree structure. A Python list ? :-) Insert/change coordinates at no costs and seek the list with a 3-liner and you are quite fast :-)  Any sophisticated tree fumbling will cost more.
Or at max use a 1D-btree thing or so for x0,x1 or a fix 16x16 array ..

-robert



More information about the Python-list mailing list