How to implement Data.Map.insertList*?

Mirko Rahn rahn at ira.uka.de
Wed Feb 23 11:31:22 EST 2005


> Would it not be more efficient to put the list into a new map, and then 
> merge the old and new maps

Sometimes yes. The function

>> insertList_union :: Ord k => [(k,a)] -> Map.Map k a -> Map.Map k a
>> insertList_union kas = Map.union (Map.fromList kas)

is faster on inserting m>n new elements into a map of size n and slower 
on inserting m<n elements.

(http://www.haskell.org//pipermail/libraries/2005-February/003336.html)

-- 
-- Mirko Rahn -- Tel +49-721 608 7504 --
--- http://liinwww.ira.uka.de/~rahn/ ---


More information about the Libraries mailing list