range-set-list 0.0.5 → 0.0.6
raw patch · 4 files changed
+18/−3 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.RangeSet.List: size :: Enum a => RSet a -> Int
Files
- CHANGELOG.md +4/−0
- range-set-list.cabal +1/−1
- src/Data/RangeSet/List.hs +6/−0
- tests/Tests.hs +7/−2
CHANGELOG.md view
@@ -1,3 +1,7 @@+### 0.0.6++- `size`+ ### 0.0.5 - Export `full`
range-set-list.cabal view
@@ -1,5 +1,5 @@ name: range-set-list-version: 0.0.5+version: 0.0.6 synopsis: Memory efficient sets with continuous ranges of elements. description: Memory efficient sets with continuous ranges of elements. List based implementation. Interface mimics "Data.Set" interface where possible. homepage: https://github.com/phadej/range-set-list
src/Data/RangeSet/List.hs view
@@ -39,6 +39,7 @@ -- * Query , null+ , size , member , notMember @@ -97,6 +98,11 @@ -- | /O(1)/. Is this the empty set? null :: RSet a -> Bool null = Prelude.null . toRangeList++-- | /O(n)/. The number of the elements in the set.+size :: Enum a => RSet a -> Int+size (RSet xs) = sum (Prelude.map f xs)+ where f (a, b) = fromEnum b - fromEnum a + 1 -- | /O(n)/. Is the element in the set? member :: (Ord a, Enum a) => a -> RSet a -> Bool
tests/Tests.hs view
@@ -67,6 +67,9 @@ elementsProp :: SetAction Int -> Property elementsProp seta = Set.elems (toSet seta) === RSet.elems (toRSet seta) +sizeProp :: SetAction Int -> Property+sizeProp seta = Set.size (toSet seta) === RSet.size (toRSet seta)+ nullProp :: SetAction Int -> Property nullProp seta = Set.null (toSet seta) === RSet.null (toRSet seta) @@ -141,8 +144,9 @@ -- Complement laws complementProps :: TestTree complementProps = testGroup "complement"- [ QC.testProperty "definition" (\a e -> RSet.member e (rs a) === RSet.notMember e (RSet.complement (rs a)))- , QC.testProperty "involutive" (\a -> rs a === RSet.complement (RSet.complement (rs a)))+ [ QC.testProperty "definition" (\a e -> RSet.member e (rs a) === RSet.notMember e (RSet.complement (rs a)))+ , QC.testProperty "involutive" (\a -> rs a === RSet.complement (RSet.complement (rs a)))+ , QC.testProperty "(full \\\\)" (\a -> RSet.complement (rs a) === RSet.full RSet.\\ (rs a)) ] where rs = rangeToRSet :: RSetAction Int -> RSet Int @@ -159,6 +163,7 @@ qcProps :: TestTree qcProps = testGroup "QuickCheck properties" [ QC.testProperty "element operations similar" elementsProp+ , QC.testProperty "size consistent" sizeProp , QC.testProperty "null operation similar" nullProp , QC.testProperty "member operation similar" memberProp , QC.testProperty "notMember operation similar" notMemberProp