« Return to Thread: (OT?): List of ranges

(OT?): List of ranges

by Johannes Schneider-5 :: Rate this Message:

Reply to Author | View in Thread

Hi,

I have a bookkeeping problem. I have a big, big range of possible ids
and need a way to find out whether one id has already been used.

My current (very simple implementation) consists of a sorted list of
objects that cover an id range (each object has a start and end id).
Now I need a collection implementation that offers an efficient way to
find an object for *any* id of its range.

Example:
Object 1: [1-3]
Object 2: [7-300]

Now I have the id "200" and have to find out which object's range
contains that id. At the moment I have a simple list and iterate over
every object... But of course that is not very efficient for big ranges.
Using a map is a possibility, but since the id ranges are very, very big
(several millions) this is not very efficient.
I also want to merge two objects if they are direct neighbors.

Do you have any idea how I could solve that problem? Is there any
collection out there that helps me to solve that?



Thanks,

Johannes


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: (OT?): List of ranges