[commit: containers] master: Add fromSet method. (044579a)
Paolo Capriotti
p.capriotti at gmail.com
Thu Jul 19 21:12:58 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/containers
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/044579a42383a1de214717e66823b1f5c7869c0b
>---------------------------------------------------------------
commit 044579a42383a1de214717e66823b1f5c7869c0b
Author: Milan Straka <fox at ucw.cz>
Date: Wed Apr 25 18:54:04 2012 +0200
Add fromSet method.
Following a proposal on libraries at ..., we add fromSet method to Map and
IntMap:
Map.fromSet :: (k -> a) -> Set k -> Map k a
IntMap.fromSet :: (Key -> a) -> IntSet -> IntMap a
It is implemented using exported Set and IntSet constructors.
Map.fromSet is trivial, as Map and Set have the same structure.
The IntMap.fromSet implementation is more complicated, as IntSet uses
dense representation of several last leves of the trie.
Data/IntMap/Base.hs | 62 +++++++++++++++++++++++++++++++++----------
Data/IntMap/Lazy.hs | 3 +-
Data/IntMap/Strict.hs | 36 ++++++++++++++++++++++++-
Data/Map/Base.hs | 27 +++++++++++++-----
Data/Map/Lazy.hs | 3 +-
Data/Map/Strict.hs | 19 ++++++++++++-
tests/intmap-properties.hs | 22 ++++++++++++---
tests/map-properties.hs | 22 ++++++++++++---
8 files changed, 157 insertions(+), 37 deletions(-)
Diff suppressed because of size. To see it, use:
git show 044579a42383a1de214717e66823b1f5c7869c0b
More information about the Cvs-libraries
mailing list