The signature TWO_PHASE_NUMBERING combines the signatures ONGOING_NUMBERING and NUMBERING. It describes a numbering process that is organized in two phases. During the first phase, the numbering is ongoing: one can encode keys, but not decode. Applying the functor Done() ends the first phase. A fixed numbering then becomes available, which gives access to the total number n of encoded keys and to both encode and decode functions.

type t

The type t of values of interest.

val encode : t -> int

encode maps a value of type t to a unique integer code. If applied twice to the same value, encode returns the same code; if applied to a value that has never been encountered, it returns a fresh code.

val current : unit -> int

current() returns the next available code, which is also the number of values that have been encoded so far.

val has_been_encoded : t -> bool

has_been_encoded x determines whether the value x has been encoded already.

module Done () : sig ... end

The functor Done ends the numbering process.