Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data DisjointMap k v
- empty :: DisjointMap k v
- singleton :: k -> v -> DisjointMap k v
- singletons :: Eq k => Set k -> v -> DisjointMap k v
- insert :: (Ord k, Monoid v) => k -> v -> DisjointMap k v -> DisjointMap k v
- union :: (Ord k, Monoid v) => k -> k -> DisjointMap k v -> DisjointMap k v
- lookup :: Ord k => k -> DisjointMap k v -> Maybe v
- representative :: Ord k => k -> DisjointMap k v -> Maybe k
- representative' :: Ord k => k -> DisjointMap k v -> (Maybe k, DisjointMap k v)
- toLists :: Ord k => DisjointMap k v -> [([k], v)]
Documentation
data DisjointMap k v Source #
empty :: DisjointMap k v Source #
singleton :: k -> v -> DisjointMap k v Source #
Create a disjoint set with one member. O(1).
singletons :: Eq k => Set k -> v -> DisjointMap k v Source #
Create a disjoint set where all members are equal.
insert :: (Ord k, Monoid v) => k -> v -> DisjointMap k v -> DisjointMap k v 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 k, Monoid v) => k -> k -> DisjointMap k v -> DisjointMap k v 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 k => k -> DisjointMap k v -> Maybe k Source #
Find the set representative for this input.
representative' :: Ord k => k -> DisjointMap k v -> (Maybe k, DisjointMap k v) Source #
Find the set representative for this input. Returns a new disjoint set in which the path has been compressed.
toLists :: Ord k => DisjointMap k v -> [([k], v)] Source #