i need an associative data structure (like finitemap) which will map data elements to Doubles. i don't need to be able to remove elements and don't even need to insert elements once i've built the structure; all i really care about is fast lookup. i have reasonable instances of Eq and Ord and probably any other reasonable comparitive metric you could think of. moreover, when i'm creating the data structure, i *know* the (approximate) relative frequency of each element. that is, i know that on average i will need to get the Double corresponding to element 'a' ten times more frequently than the Double corresponding to element 'b'. does anyone have any suggestions for data structures to solve such a problem. i'm currently using FiniteMap, but would like something faster (btw, there are a LOT of these elements -- around 1million or so). - Hal -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
perhaps you can modify 'gperf' (the gnu perfect hash function generator) to output haskell rather than c. i actually looked into this before, it should not be too tough as gperf always generates a generic polynomial and just the coefficients are different for diffirente input, it would be pretty easy to awk those out and reimplement the generic function in haskell. alternativly you could roll your own.. some useful information is here http://burtleburtle.net/bob/hash/perfect.html and around. John On Wed, Apr 17, 2002 at 11:11:50AM -0700, Hal Daume III wrote:
i need an associative data structure (like finitemap) which will map data elements to Doubles. i don't need to be able to remove elements and don't even need to insert elements once i've built the structure; all i really care about is fast lookup. i have reasonable instances of Eq and Ord and probably any other reasonable comparitive metric you could think of. moreover, when i'm creating the data structure, i *know* the (approximate) relative frequency of each element. that is, i know that on average i will need to get the Double corresponding to element 'a' ten times more frequently than the Double corresponding to element 'b'.
does anyone have any suggestions for data structures to solve such a problem. i'm currently using FiniteMap, but would like something faster (btw, there are a LOT of these elements -- around 1million or so).
- Hal
-- Hal Daume III
"Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
-- --------------------------------------------------------------------------- John Meacham - California Institute of Technology, Alum. - john@repetae.net ---------------------------------------------------------------------------
participants (2)
-
Hal Daume III -
John Meacham