disjoint-containers-0.1.0: Disjoint containers

Safe HaskellSafe
LanguageHaskell2010

Data.DisjointSet

Synopsis

Documentation

singleton :: a -> DisjointSet a Source #

Create a disjoint set with one member. O(1).

singletons :: Eq a => Set a -> DisjointSet a Source #

Create a disjoint set where all members are equal.

insert :: Ord a => a -> DisjointSet a -> DisjointSet a Source #

Insert x into the disjoint set. If it is already a member, then do nothing, otherwise x has no equivalence relations. O(logn).

union :: Ord a => a -> a -> DisjointSet a -> DisjointSet a Source #

Create an equivalence relation between x and y. If either x or y are not already is the disjoint set, they are first created as singletons.

representative :: Ord a => a -> DisjointSet a -> Maybe a Source #

Find the set representative for this input.

representative' :: Ord a => a -> DisjointSet a -> (Maybe a, DisjointSet a) Source #

Find the set representative for this input. Returns a new disjoint set in which the path has been compressed.

toLists :: Ord a => DisjointSet a -> [[a]] Source #