package unionFind

  1. Overview
  2. Docs

Module UnionFind.HeterogeneousSource

A homogeneous store can serve as a heterogeneous store. This requires dynamic tests, which have a runtime cost.

Parameters

module S : sig ... end

Signature

Sourcetype store
Sourceval new_store : unit -> store

new_store() creates an empty store.

Sourceval copy : store -> store

copy s returns a copy of the store s. Every reference that is valid in the store s is also valid in the new store, and has the same content in both stores. The two stores are independent of one another: updating one of them does not affect the other. When supported, copy is cheap: it can be expected to run in constant time. However, some stores does not support copy; in that case, an unspecified exception is raised.

Sourcetype 'a rref

A reference of type 'a rref can be thought of as (a pointer to) an object that exists in some store.

Sourceval make : store -> 'a -> 'a rref

make s v creates a fresh reference in the store s and sets its content to v. It updates the store in place and returns the newly-created reference.

Sourceval get : store -> 'a rref -> 'a

get s x reads the current content of the reference x in the store s. It may update the store in place, and returns the current content of the reference.

Sourceval set : store -> 'a rref -> 'a -> unit

set s x v updates the store s so as to set the content of the reference x to v. It updates the store in place.

Sourceval eq : store -> 'a rref -> 'a rref -> bool

eq s x y determines whether the references x and y are the same reference. It may update the store in place, and returns a Boolean result. The references x and y must belong to the store s.