baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
so it is a table of intervals associated with some numbers. Intervals cannot overlap (Thank U G) but some intervals can remain empty like 18-18 or 21-22. the interval range is form 1 to 1000000000. associated values are from 1 to 5000000. the thing is when i am retrieving associated numbers I have to be able to make a query of the type:23-45 12 11-17 2 45-134 23 10-10 65 1-1 45 19-20 10 ...
"Q: What is the value associated with 50?"
"A: It is 23."
Is it clear what I am trying to get? Now, I could create a hash table for all possible values from 45 to 134 and associate each key to 23 and get the job done, but this seam like too memory wasteful. And since this looks like a trivial task I guess somebody already solved it efficiently and I can only be grateful if she/he is willing to share the knowledge :)
thank you
baxy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hashing intervals
by choroba (Cardinal) on Jul 29, 2013 at 16:09 UTC | |
|
Re: hashing intervals
by daxim (Curate) on Jul 29, 2013 at 15:35 UTC | |
|
Re: hashing intervals
by choroba (Cardinal) on Jul 29, 2013 at 15:51 UTC | |
by Skeeve (Parson) on Jul 30, 2013 at 06:39 UTC | |
by LanX (Saint) on Jul 30, 2013 at 09:23 UTC | |
by Skeeve (Parson) on Jul 31, 2013 at 09:17 UTC | |
by LanX (Saint) on Jul 31, 2013 at 12:09 UTC | |
| |
|
Re: hashing intervals
by LanX (Saint) on Jul 29, 2013 at 16:41 UTC | |
|
Re: hashing intervals
by hdb (Monsignor) on Jul 29, 2013 at 15:47 UTC | |
|
Re: hashing intervals
by Laurent_R (Canon) on Jul 29, 2013 at 17:44 UTC | |
|
Re: hashing intervals
by locked_user sundialsvc4 (Abbot) on Jul 30, 2013 at 03:11 UTC |