bitset 1.4.0 → 1.4.1
raw patch · 4 files changed
+27/−26 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES +10/−0
- bitset.cabal +1/−1
- src/Data/BitSet/Dynamic.hs +4/−25
- tests/Tests.hs +12/−0
CHANGES view
@@ -3,6 +3,16 @@ Here you can see the full list of changes between each bitset release. +Version 1.4.1+-------------++Released on April 24th, 2013++- Removed 'clearBitInteger' which didn't update the size field of+ the newly created 'Integer'. Turns out it's completely non-trivial+ to implement.++ Version 1.4.0 -------------
bitset.cabal view
@@ -1,5 +1,5 @@ Name: bitset-Version: 1.4.0+Version: 1.4.1 Synopsis: A space-efficient set data structure. Description: A /bit set/ is a compact data structure, which maintains a set of members
src/Data/BitSet/Dynamic.hs view
@@ -78,11 +78,10 @@ import GHC.Base (Int(..), divInt#, modInt#) import GHC.Exts (popCnt#) import GHC.Integer.GMP.Internals (Integer(..))-import GHC.Prim (State#, RealWorld, Int#, Word#, ByteArray#,+import GHC.Prim (Int#, Word#, (+#), (==#), (>=#), (<#), negateInt#,- word2Int#, int2Word#, plusWord#, realWorld#,- newByteArray#, copyByteArray#, writeWordArray#,- indexWordArray#, unsafeFreezeByteArray#, sizeofByteArray#)+ word2Int#, int2Word#, plusWord#,+ indexWordArray#) import GHC.Word (Word(..)) import Control.DeepSeq (NFData(..))@@ -122,7 +121,7 @@ setBit (FasterInteger x) = FasterInteger . setBit x {-# SPECIALIZE INLINE setBit :: FasterInteger -> Int -> FasterInteger #-} - clearBit (FasterInteger x) = FasterInteger . clearBitInteger x+ clearBit (FasterInteger x) = FasterInteger . clearBit x {-# SPECIALIZE INLINE clearBit :: FasterInteger -> Int -> FasterInteger #-} popCount (FasterInteger x) = I# (word2Int# (popCountInteger x))@@ -275,23 +274,3 @@ where (# !block#, !offset# #) = b# `divModInt#` WORD_SIZE_IN_BITS# {-# NOINLINE testBitInteger #-}--clearBitInteger :: Integer -> Int -> Integer-clearBitInteger (S# i#) b = S# i# `clearBit` b-clearBitInteger i@(J# s# d0#) (I# b#) =- if b# <# 0# || block# >=# abs# s#- then i- else J# s# (go realWorld#)- where- (# !block#, !offset# #) = b# `divModInt#` WORD_SIZE_IN_BITS#-- go :: State# RealWorld -> ByteArray#- go state0 =- let !n = sizeofByteArray# d0#- (# state1, !d1 #) = newByteArray# n state0- state2 = copyByteArray# d0# 0# d1 0# n state1- !(W# chunk) = W# (indexWordArray# d0# block#) `clearBit` I# offset#- state3 = writeWordArray# d1 block# chunk state2- (# _state4, d2 #) = unsafeFreezeByteArray# d1 state3- in d2-{-# NOINLINE clearBitInteger #-}
tests/Tests.hs view
@@ -80,6 +80,16 @@ propEmpty :: Word16 -> Bool propEmpty x = x `BS.notMember` BS.empty +propNullEmpty :: Bool+propNullEmpty = BS.null bs where+ bs :: BitSet Word16+ bs = BS.empty++propNullAfterDelete :: [Word16] -> Bool+propNullAfterDelete xs = BS.null bs where+ bs :: BitSet Word16+ bs = foldr BS.delete (foldr BS.insert BS.empty xs) xs+ propIntersectionWithSelf :: [Word16] -> Bool propIntersectionWithSelf xs = all (`BS.member` bs) xs where@@ -181,6 +191,8 @@ , testProperty "toList" propToList , testProperty "fromList" propFromList , testProperty "empty" propEmpty+ , testProperty "native empty is null" propNullEmpty+ , testProperty "generated empty is null" propNullAfterDelete , testProperty "intersection with self" propIntersectionWithSelf , testProperty "intersection" propIntersection , testProperty "difference with self" propDifferenceWithSelf