![]() | ![]() | ![]() |
|
Unionfind provides operations on disjoint sets. Sets can be joined and membership for element can be checked.
type <'a,'b>t; | |
Type of union-find object with elements of type 'a and sets of type 'b. |
<'a,'b>t create(); | |
Return new union-find object. |
<'a,'b>t create_ex(int elts_size_hint, int sets_size_hint); | |
Return new union-find object, initialize internal hashes for elements and sets with given sizes, this might be more efficient then plain Unionfind::create(). |
void make_set(<'a,'b>t u, 'b s); | |
Add new empty set s to u. Raise Invalid_argument if s is already present in u. |
void insert(<'a,'b>t u, 'a e, 'b s); | |
Add element e to s in u. Raise Invalid_argument if e is already in some set in u. Raise Not_found if s is not in u. |
void union_sets(<'a,'b>t u, 'b dst, 'b src); | |
Add set src to dst. Unionfind::find will now return dst for each element it used to return src. Unionfind::insert(u, x, src) will from now on add elements to dst, i.e. src is not removed from u, it's just effectively joined with dst. Raise Not_found if dst or src are not in u. |
'b find(<'a,'b>t u, 'a e); | |
Return set associated with element e in u. Raise Not_found if e is not in u. |