iota-0.1.0.0
Safe HaskellNone
LanguageGHC2021

Data.IntervalSet

Synopsis

Documentation

newtype IntervalSet Source #

Constructors

IntervalSet (IntMap Int) 

Instances

Instances details
IsList IntervalSet Source # 
Instance details

Defined in Data.IntervalSet

Associated Types

type Item IntervalSet 
Instance details

Defined in Data.IntervalSet

Show IntervalSet Source # 
Instance details

Defined in Data.IntervalSet

Eq IntervalSet Source # 
Instance details

Defined in Data.IntervalSet

type Item IntervalSet Source # 
Instance details

Defined in Data.IntervalSet

intervalIS :: (Int, Int) -> IntervalSet Source #

>>> intervalIS (0, 1)
[(0,1)]
>>> intervalIS (1, 0)
[]

insertIS :: Int -> IntervalSet -> IntervalSet Source #

>>> insertIS 2 $ fromListIS [(0,1),(3,4)]
[(0,4)]
>>> insertIS 1 $ fromListIS [(0,1)]
[(0,1)]

insertIntervalIS :: (Int, Int) -> IntervalSet -> IntervalSet Source #

>>> insertIntervalIS (2,4) $ fromListIS [(1,1),(3,3),(5,5)]
[(1,5)]

deleteIS :: Int -> IntervalSet -> IntervalSet Source #

>>> deleteIS 1 $ fromListIS [0..2]
[(0,0),(2,2)]

deleteIntervalIS :: (Int, Int) -> IntervalSet -> IntervalSet Source #

>>> deleteIntervalIS (1,7) $ fromListIS [(0,1),(3,5),(7,8)]
[(0,0),(8,8)]
>>> deleteIntervalIS (1,1) $ fromListIS [(0,0)]
[(0,0)]

memberIS :: Int -> IntervalSet -> Bool Source #

>>> memberIS 0 (fromListIS [(-1,1)])
True
>>> memberIS 1 (fromListIS [(-1,1)])
True
>>> memberIS 2 (fromListIS [(-1,1)])
False

lookupIS :: Int -> IntervalSet -> Maybe (Int, Int) Source #

>>> lookupIS (-2) $ intervalIS (-1,1)
Nothing
>>> lookupIS (-1) $ intervalIS (-1,1)
Just (-1,1)
>>> lookupIS 0 $ intervalIS (-1,1)
Just (-1,1)
>>> lookupIS 1 $ intervalIS (-1,1)
Just (-1,1)
>>> lookupIS 2 $ intervalIS (-1,1)
Nothing

lookupIntervalIS :: (Int, Int) -> IntervalSet -> [(Int, Int)] Source #

>>> lookupIntervalIS (1,8) $ fromList [(0,2),(4,5),(7,9)]
[(0,2),(4,5),(7,9)]
>>> lookupIntervalIS (3,6) $ fromList [(0,2),(4,5),(7,9)]
[(4,5)]
>>> lookupIntervalIS (3,3) $ fromList [(0,2),(4,5),(7,9)]
[]
>>> lookupIntervalIS (0, 1) $ fromList [(1, 2)]
[(1,2)]
>>> lookupIntervalIS (0, 1) $ fromList [(-1, 0)]
[(-1,0)]

mex :: IntervalSet -> Int Source #

minimum excluded value

>>> mex $ fromListIS [(0,1),(3,5)]
2
>>> mex $ intervalIS (1, 5)
0