Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data DisjointSet a
- empty :: DisjointSet a
- singleton :: a -> DisjointSet a
- singletons :: Eq a => Set a -> DisjointSet a
- insert :: Ord a => a -> DisjointSet a -> DisjointSet a
- union :: Ord a => a -> a -> DisjointSet a -> DisjointSet a
- representative :: Ord a => a -> DisjointSet a -> Maybe a
- representative' :: Ord a => a -> DisjointSet a -> (Maybe a, DisjointSet a)
- toLists :: Ord a => DisjointSet a -> [[a]]
Documentation
data DisjointSet a Source #
empty :: DisjointSet a Source #
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 #