rangeset-0.1.0.0: Efficient sets for semi-contiguous data
LicenseBSD-3-Clause
MaintainerJamie Willis
Stabilitystable
Safe HaskellSafe
LanguageHaskell2010

Data.RangeSet

Description

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: 0.0.1.0

Synopsis

Documentation

data RangeSet a Source #

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: 0.0.1.0

Instances

Instances details
Show (RangeSet a) Source # 
Instance details

Defined in Data.RangeSet.Internal.Types

Methods

showsPrec :: Int -> RangeSet a -> ShowS #

show :: RangeSet a -> String #

showList :: [RangeSet a] -> ShowS #

Eq (RangeSet a) Source # 
Instance details

Defined in Data.RangeSet.Internal.Types

Methods

(==) :: RangeSet a -> RangeSet a -> Bool #

(/=) :: RangeSet a -> RangeSet a -> Bool #

singleton :: Enum a => a -> RangeSet a Source #

A RangeSet containing a single value.

Since: 0.0.1.0

null :: RangeSet a -> Bool Source #

Is this set empty?

Since: 0.0.1.0

full :: forall a. (Enum a, Bounded a) => RangeSet a -> Bool Source #

Is this set full?

Since: 0.0.1.0

isSingle :: RangeSet a -> Bool Source #

Does this set contain a single element?

Since: 0.0.1.0

extractSingle :: Enum a => RangeSet a -> Maybe a Source #

Possibly extract the element contained in the set if it is a singleton set.

Since: 0.0.1.0

size :: RangeSet a -> Int Source #

Return the number of elements in the set.

Since: 0.0.1.0

sizeRanges :: RangeSet a -> Int Source #

Return the number of contiguous ranges that populate the set.

Since: 0.0.1.0

notMember :: Enum a => a -> RangeSet a -> Bool Source #

Test whether or not a given value is not found within the set.

Since: 0.0.1.0

findMin :: Enum a => RangeSet a -> Maybe a Source #

Find the minimum value within the set, if one exists.

Since: 0.0.1.0

findMax :: Enum a => RangeSet a -> Maybe a Source #

Find the maximum value within the set, if one exists.

Since: 0.0.1.0

complement :: forall a. (Bounded a, Enum 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: 0.0.1.0

isSubsetOf :: RangeSet a -> RangeSet a -> Bool Source #

Tests if all the elements of the first set appear in the second.

Since: 0.0.1.0

isProperSubsetOf :: 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: 0.0.1.0

allLess :: Enum a => a -> RangeSet a -> RangeSet a Source #

Filters a set by removing all values greater than or equal to the given value.

Since: 0.0.1.0

allMore :: Enum a => a -> RangeSet a -> RangeSet a Source #

Filters a set by removing all values less than or equal to the given value.

Since: 0.0.1.0

elems :: Enum a => RangeSet a -> [a] Source #

Returns all the elements found within the set.

Since: 0.0.1.0

unelems :: forall a. (Bounded a, Enum a) => RangeSet a -> [a] Source #

Returns all the values that are not found within the set.

Since: 0.0.1.0