Syntactic Confectionery Delight | |
PerlMonks |
Re: Assemble times into rangesby dws (Chancellor) |
on May 05, 2001 at 23:26 UTC ( [id://78281]=note: print w/replies, xml ) | Need Help?? |
Probably a better approach would be to improve the data structures.
How about a brute force space-for-time tradeoff? A 3.8Mb bitmap can represent an entire year's worth of seconds. Allocate and clear the bitmap, then turn on bits for second within intervals. The probe to determine whether a given time occurs within at least one interval is O(1). This merges intervals, so it's not useful if you're trying to determine which intervals a given time occurs within. A tree structure is more appropriate for that. "It's not the Zen way, but it gets the job done." --Garrison Keillor
In Section
Meditations
|
|