Hashtbl: hash tables and hash functions
Hash tables are hashed association tables, with in-place modification.
type 'b t
The type of hash tables from type
Xtypes.window to type
val create : int -> 'b t
Hashtbl.create n creates a new, empty hash table, with
n. The table grows as needed, so
just an initial guess. Better results are said to be
n is a prime number.
n is less than 1.
val clear : 'b t -> unit
Empty a hash table.
val add : 'b t -> Xtypes.window -> 'b -> unit
Hashtbl.add tbl x y adds a binding of
y in table
Previous bindings for
x are not removed, but simply
hidden. That is, after performing
Hashtbl.remove tbl x,
the previous binding for
x, if any, is restored.
(Same behavior as with association lists.)
val find : 'b t -> Xtypes.window -> 'b
Hashtbl.find tbl x returns the current binding of
Not_found if no such binding exists.
val find_all : 'b t -> Xtypes.window -> 'b list
Hashtbl.find_all tbl x returns the list of all data
The current binding is returned first, then the previous
bindings, in reverse order of introduction in the table.
val mem : 'b t -> Xtypes.window -> bool
Hashtbl.mem tbl x checks if
x is bound in
val remove : 'b t -> Xtypes.window -> unit
Hashtbl.remove tbl x removes the current binding of
restoring the previous binding if it exists.
It does nothing if
x is not bound in
val iter : (Xtypes.window -> 'b -> unit) -> 'b t -> unit
Hashtbl.iter f tbl applies
f to all bindings in table
f receives the key as first argument, and the associated value
as second argument. The order in which the bindings are passed to
f is unspecified. Each binding is presented exactly once
Go to the first, previous, next, last section, table of contents.