[Haskell-cafe] Haskell-Cafe Digest, Vol 90, Issue 48

Louis Wasserman wasserman.louis at gmail.com
Thu Feb 24 21:05:47 CET 2011

> Another common usage for Map is as a functional integer-indexed
> random access array.
> Once I implemented the standard algorithm for random shuffle
> of a list using Data.Map Int. It was much nicer than the STArray
> version, in my opinion. But when I tried switching to Data.IntMap,
> hoping to make it faster, I was devastatingly disappointed. Now
> I understand why.

A couple thoughts:

If you're going to provide an isSingleton method, provide

getSingleton :: IntMap m -> Maybe (Int, a)

which is trivial based on the current implementation.

For my TrieMap package, I've been working on my WordMap implementation
 (Using Words as keys makes my life easier, and it doesn't take too much
work to write a wrapper that provides an order-preserving bijection from Int
to Word.)  It provides O(1) size, but its design reflects my willingness to
trade memory and code size for speed. ;)

Louis Wasserman
wasserman.louis at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110224/a3361ccd/attachment.htm>

More information about the Haskell-Cafe mailing list