module type Hashconsing_tbl =functor (
Data
:
sig
include Datatype.S
The hashconsed datatype
val equal_internal : t -> t -> bool
Equality on the datatype internally used by the built table.
val hash_internal : t -> int
Hash function for datatype internally used by the built table.
val initial_values : t list
Pre-existing values stored in the built table and shared by all existing projects.
end
) ->
functor (
Info
:
Info_with_size
) ->
Weak_hashtbl
with type data = Data.t
Signature for the creation of projectified hashconsing tables..
Parameters: |
|
include State_builder.S
Hashtbl are a standard computation.
BUT it is INCORRECT to use projectified hashtables if keys have a
custom rehash
function (see Project.DATATYPE_OUTPUT.rehash
)
type
data
val merge : data -> data
merge x
returns an instance of x
found in the table if any, or else
adds x
and return x
.
val add : data -> unit
add x
adds x
to the table. If there is already an instance of x
,
it is unspecified which one will be returned by subsequent calls to
find
and merge
.
val clear : unit -> unit
Clear the table.
val count : unit -> int
Length of the table.
val iter : (data -> unit) -> unit
val fold : (data -> 'a -> 'a) -> 'a -> 'a
val find : data -> data
find x
returns an instance of x
found in table.
@Raise Not_found if there is no such element.
val find_all : data -> data list
find_all x
returns a list of all the instances of x
found in t.
val mem : data -> bool
mem x
returns true
if there is at least one instance of x
in the
table, false
otherwise.
val remove : data -> unit
remove x
removes from the table one instance of x
. Does nothing if
there is no instance of x
.