package core

  1. Overview
  2. Docs
Industrial strength alternative to OCaml's standard library

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.16.2.tar.gz
md5=bcac85c0ec5795ccabf1dccf0968ecd9
sha512=2e68556773549e0bf302c8733c9fc57df3c0fd73a1b547dc17097f74c5b5482c816ef89853b437e49452da7c124ef32a8a0de0dff64d71145b2ab11befbe5bb2

doc/core/Core/Union_find/index.html

Module Core.Union_findSource

Imperative data structure for representing disjoint sets.

Union find is used to implement an equivalence relation on objects, where the equivalence relation can dynamically be coarsened by "union"ing two equivalence classes together.

All of the operations are effectively (amortized) constant time.

See Wikipedia.

This implementation is not thread-safe.

Sourcetype 'a t

type 'a t is the type of objects, where each object is part of an equivalence class that is associated with a single value of type 'a.

include Base.Invariant.S1 with type 'a t := 'a t
Sourceval invariant : ('a -> unit) -> 'a t -> unit
Sourceval create : 'a -> 'a t

create v returns a new object in its own equivalence class that has value v.

Sourceval get : 'a t -> 'a

get t returns the value of the class of t.

Sourceval set : 'a t -> 'a -> Base.Unit.t

set t v sets the value of the class of t to v.

Sourceval same_class : 'a t -> 'a t -> Base.Bool.t

same_class t1 t2 returns true iff t1 and t2 are in the same equivalence class.

Sourceval union : 'a t -> 'a t -> Base.Unit.t

union t1 t2 makes the class of t1 and the class of t2 be the same (if they are already equal, then nothing changes). The value of the combined class is the value of t1 or t2; it is unspecified which. After union t1 t2, it will always be the case that same_class t1 t2.

Sourcemodule Private : sig ... end