Johan Tibell wrote:
>
> I'm working on a patch that provides O(1) size right now. The trick is
> to define HashMap as:
>
> data HashMap k v = HM {-# UNPACK #-} !Int !(Tree k v)

Another possibility is:

data HashMap k v = HM Int !(Tree k v)

hashMap t = HM (treeSize t) t

That way size is O(n) on first use but O(1) afterwards. Then again, if
someone really needs this they can program it themselves. I've never
needed an O(1) size for maps.

Roman




_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to