in reply to Hash keyed on ranges

Why are you using a hash? Why don't you use an array for this? If you really feel guilty about space, you can use an array whose values for the given range are the key into the hash.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Replies are listed 'Best First'.
Re: Re: Hash keyed on ranges
by ColonelPanic (Friar) on May 07, 2004 at 14:05 UTC
    If space is really too much of an issue to have an array of every value in the range, but you need more speed than a simplistic solution like my previous post will give you, than you could store the sorted list of keys from your hash and binary search it. This is probably the best compromise if you have major speed and memory concerns.

    Of course, this all depends on what the data is like, and how it is used. A simpler solution will almost certainly suffice, unless you are accessing megabytes of data thousands of times.


    When's the last time you used duct tape on a duct? --Larry Wall