Safe Haskell | None |
---|---|
Language | GHC2021 |
Data.IntervalSet
Synopsis
- newtype IntervalSet = IntervalSet (IntMap Int)
- emptyIS :: IntervalSet
- singletonIS :: Int -> IntervalSet
- intervalIS :: (Int, Int) -> IntervalSet
- insertIS :: Int -> IntervalSet -> IntervalSet
- insertIntervalIS :: (Int, Int) -> IntervalSet -> IntervalSet
- deleteIS :: Int -> IntervalSet -> IntervalSet
- deleteIntervalIS :: (Int, Int) -> IntervalSet -> IntervalSet
- memberIS :: Int -> IntervalSet -> Bool
- lookupIS :: Int -> IntervalSet -> Maybe (Int, Int)
- lookupIntervalIS :: (Int, Int) -> IntervalSet -> [(Int, Int)]
- mex :: IntervalSet -> Int
- fromListIS :: [(Int, Int)] -> IntervalSet
- toListIS :: IntervalSet -> [(Int, Int)]
Documentation
newtype IntervalSet Source #
Constructors
IntervalSet (IntMap Int) |
Instances
IsList IntervalSet Source # | |||||
Defined in Data.IntervalSet Associated Types
Methods fromList :: [Item IntervalSet] -> IntervalSet # fromListN :: Int -> [Item IntervalSet] -> IntervalSet # toList :: IntervalSet -> [Item IntervalSet] # | |||||
Show IntervalSet Source # | |||||
Defined in Data.IntervalSet Methods showsPrec :: Int -> IntervalSet -> ShowS # show :: IntervalSet -> String # showList :: [IntervalSet] -> ShowS # | |||||
Eq IntervalSet Source # | |||||
Defined in Data.IntervalSet | |||||
type Item IntervalSet Source # | |||||
Defined in Data.IntervalSet |
singletonIS :: Int -> IntervalSet Source #
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
fromListIS :: [(Int, Int)] -> IntervalSet Source #