Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data UnionFindDiff s a = UFD {
- parentOrNegativeSizeUFD :: MVector s Int
- potentialUFD :: MVector s a
- newUnionFindDiff :: (Unbox a, Num a, PrimMonad m) => Int -> m (UnionFindDiff (PrimState m) a)
- findUFD :: (Num a, Unbox a, PrimMonad m) => UnionFindDiff (PrimState m) a -> Int -> m (Int, a)
- sizeUFD :: PrimMonad m => UnionFindDiff (PrimState m) a -> Int -> m Int
- setDiffUFD :: (Eq a, Num a, Unbox a, PrimMonad m) => UnionFindDiff (PrimState m) a -> Int -> Int -> a -> m (Maybe Bool)
- diffUFD :: (Num a, Unbox a, PrimMonad m) => UnionFindDiff (PrimState m) a -> Int -> Int -> m (Maybe a)
Documentation
data UnionFindDiff s a Source #
UFD | |
|
newUnionFindDiff :: (Unbox a, Num a, PrimMonad m) => Int -> m (UnionFindDiff (PrimState m) a) Source #
:: (Num a, Unbox a, PrimMonad m) | |
=> UnionFindDiff (PrimState m) a | |
-> Int | |
-> m (Int, a) | (representative, potential) |
setDiffUFD :: (Eq a, Num a, Unbox a, PrimMonad m) => UnionFindDiff (PrimState m) a -> Int -> Int -> a -> m (Maybe Bool) Source #
hx - hy = d
>>>
uf <- newUnionFindDiff @Int 2
>>>
setDiffUFD uf 1 0 1
Just True>>>
setDiffUFD uf 1 0 999
Nothing>>>
setDiffUFD uf 1 0 1
Just False>>>
setDiffUFD uf 0 1 (-1)
Just False
diffUFD :: (Num a, Unbox a, PrimMonad m) => UnionFindDiff (PrimState m) a -> Int -> Int -> m (Maybe a) Source #
hx - hy
>>>
uf <- newUnionFindDiff @Int 3
>>>
setDiffUFD uf 1 0 1
Just True>>>
diffUFD uf 1 0
Just 1>>>
diffUFD uf 0 1
Just (-1)>>>
diffUFD uf 0 2
Nothing>>>
setDiffUFD uf 2 1 2
Just True>>>
diffUFD uf 2 1
Just 2>>>
diffUFD uf 2 0
Just 3