iota-0.1.0.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.UnionFind.Diff

Synopsis

Documentation

data UnionFindDiff s a Source #

Constructors

UFD 

Fields

newUnionFindDiff :: (Unbox a, Num a, PrimMonad m) => Int -> m (UnionFindDiff (PrimState m) a) Source #

findUFD Source #

Arguments

:: (Num a, Unbox a, PrimMonad m) 
=> UnionFindDiff (PrimState m) a 
-> Int 
-> m (Int, a)

(representative, potential)

sizeUFD :: PrimMonad m => UnionFindDiff (PrimState m) a -> Int -> m Int Source #

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