License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
This module contains the implementation of an efficient set for contiguous data. It has a much
smaller memory footprint than a Set
, and can result in asymptotically faster operations.
Since: 2.1.0.0
Synopsis
- data RangeSet a
- empty :: RangeSet a
- singleton :: a -> RangeSet a
- null :: RangeSet a -> Bool
- full :: (Eq a, Bounded a) => RangeSet a -> Bool
- isSingle :: RangeSet a -> Bool
- extractSingle :: Eq a => RangeSet a -> Maybe a
- size :: RangeSet a -> Int
- sizeRanges :: RangeSet a -> Int
- member :: forall a. Ord a => a -> RangeSet a -> Bool
- notMember :: Ord a => a -> RangeSet a -> Bool
- findMin :: RangeSet a -> Maybe a
- findMax :: RangeSet a -> Maybe a
- insert :: forall a. (Enum a, Ord a) => a -> RangeSet a -> RangeSet a
- delete :: (Enum a, Ord a) => a -> RangeSet a -> RangeSet a
- union :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> RangeSet a
- intersection :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> RangeSet a
- difference :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> RangeSet a
- disjoint :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> Bool
- complement :: forall a. (Bounded a, Enum a, Eq a) => RangeSet a -> RangeSet a
- isSubsetOf :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> Bool
- isProperSubsetOf :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> Bool
- allLess :: (Enum a, Ord a) => a -> RangeSet a -> RangeSet a
- allMore :: (Enum a, Ord a) => a -> RangeSet a -> RangeSet a
- elems :: Enum a => RangeSet a -> [a]
- unelems :: (Bounded a, Enum a, Eq a) => RangeSet a -> [a]
- fromRanges :: (Enum a, Ord a) => [(a, a)] -> RangeSet a
- insertRange :: (Enum a, Ord a) => a -> a -> RangeSet a -> RangeSet a
- fromList :: (Enum a, Ord a) => [a] -> RangeSet a
- fold :: (a -> a -> b -> b -> b) -> b -> RangeSet a -> b
Documentation
A Set
type designed for types that are Enum
as well as Ord
. This allows the RangeSet
to
compress the data when it is contiguous, reducing memory-footprint and enabling otherwise impractical
operations like complement
for Bounded
types.
Since: 2.1.0.0
extractSingle :: Eq a => RangeSet a -> Maybe a Source #
Possibly extract the element contained in the set if it is a singleton set.
Since: 2.1.0.0
sizeRanges :: RangeSet a -> Int Source #
Return the number of contiguous ranges that populate the set.
Since: 2.1.0.0
member :: forall a. Ord a => a -> RangeSet a -> Bool Source #
Test whether or not a given value is found within the set.
Since: 2.1.0.0
notMember :: Ord a => a -> RangeSet a -> Bool Source #
Test whether or not a given value is not found within the set.
Since: 2.1.0.0
findMin :: RangeSet a -> Maybe a Source #
This deletes the right-most range of the tree. It *must not* be used with an empty tree.
Find the minimum value within the set, if one exists.
Since: 2.1.0.0
findMax :: RangeSet a -> Maybe a Source #
Find the maximum value within the set, if one exists.
Since: 2.1.0.0
insert :: forall a. (Enum a, Ord a) => a -> RangeSet a -> RangeSet a Source #
Insert a new element into the set.
Since: 2.1.0.0
delete :: (Enum a, Ord a) => a -> RangeSet a -> RangeSet a Source #
Remove an element from the set, if it appears.
Since: 2.1.0.0
union :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> RangeSet a Source #
Unions two sets together such that if and only if an element appears in either one of the sets, it will appear in the result set.
Since: 2.1.0.0
intersection :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> RangeSet a Source #
Intersects two sets such that an element appears in the result if and only if it is present in both of the provided sets.
Since: 2.1.0.0
difference :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> RangeSet a Source #
Removes all elements from the first set that are found in the second set.
Since: 2.1.0.0
disjoint :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> Bool Source #
Do two sets have no elements in common?
Since: 2.1.0.0
complement :: forall a. (Bounded a, Enum a, Eq a) => RangeSet a -> RangeSet a Source #
Inverts a set: every value which was an element is no longer an element, and every value that
was not an element now is. This is only possible on Bounded
types.
Since: 2.1.0.0
isSubsetOf :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> Bool Source #
Tests if all the elements of the first set appear in the second.
Since: 2.1.0.0
isProperSubsetOf :: (Enum a, Ord a) => RangeSet a -> RangeSet a -> Bool Source #
Tests if all the element of the first set appear in the second, but also that the first and second sets are not equal.
Since: 2.1.0.0
allLess :: (Enum a, Ord a) => a -> RangeSet a -> RangeSet a Source #
Filters a set by removing all values greater than or equal to the given value.
Since: 2.1.0.0
allMore :: (Enum a, Ord a) => a -> RangeSet a -> RangeSet a Source #
Filters a set by removing all values less than or equal to the given value.
Since: 2.1.0.0
elems :: Enum a => RangeSet a -> [a] Source #
Returns all the elements found within the set.
Since: 2.1.0.0
unelems :: (Bounded a, Enum a, Eq a) => RangeSet a -> [a] Source #
Returns all the values that are not found within the set.
Since: 2.1.0.0
fromRanges :: (Enum a, Ord a) => [(a, a)] -> RangeSet a Source #
Constructs a RangeSet
given a list of ranges.
Since: 2.1.0.0
insertRange :: (Enum a, Ord a) => a -> a -> RangeSet a -> RangeSet a Source #
Inserts a range into a RangeSet
.
Since: 2.1.0.0