range-set-0.1.0: A set of elements represented as a list of ranges.

Copyright(c) 2016 Micxjo Funkcio
LicenseBSD3
Maintainermicxjo@fastmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Data.RangeSet

Contents

Description

 

Synopsis

RangeSet type

data RangeSet a Source

A set of elements, represented as a (possibly empty) list of disjoint ranges.

Instances

Eq a => Eq (RangeSet a) Source 
Show a => Show (RangeSet a) Source 
(Ord a, Enum a, Bounded a) => Monoid (RangeSet a) Source 
(Ord a, Enum a, Bounded a) => Semigroup (RangeSet a) Source 

Construction

empty :: RangeSet a Source

Create an empty set.

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

Create a singleton set.

rangeSet :: (Ord a, Enum a) => a -> a -> RangeSet a Source

Create a set from (min a b) to (max a b), inclusive.

insert :: (Enum a, Ord a, Bounded a) => a -> RangeSet a -> RangeSet a Source

Insert an elemen in the set.

Query

member :: Ord a => a -> RangeSet a -> Bool Source

Is the element in the set?

notMember :: Ord a => a -> RangeSet a -> Bool Source

Is the element not in the set?

size :: Num a => RangeSet a -> a Source

The number of element in the set.

isEmpty :: RangeSet a -> Bool Source

Is the set empty?

isSingleton :: Eq a => RangeSet a -> Bool Source

Does the set contain exactly one element?

ranges :: RangeSet a -> [Range a] Source

The sub-ranges of the set.

Combine

union :: (Ord a, Enum a, Bounded a) => RangeSet a -> RangeSet a -> RangeSet a Source

The union of two sets.

unions :: (Ord a, Enum a, Bounded a, Foldable t) => t (RangeSet a) -> RangeSet a Source

The union of a list of sets: (union == foldl union empty)

Conversion

toList :: Enum a => RangeSet a -> [a] Source

All of the elements of the set.

toAscList :: Enum a => RangeSet a -> [a] Source

All of the elements of the set, in ascending order.

toDescList :: Enum a => RangeSet a -> [a] Source

All of the elements of the set, in descending order.