package containers

  1. Overview
  2. Docs

Parameters

Signature

type key = X.t
type 'a t

A hashtable for keys of type key and values of type 'a

val create : ?size:int -> 'a -> 'a t

create d makes a new table that maps every key to d by default.

  • parameter size

    optional size of the initial table

val create_with : ?size:int -> (key -> 'a) -> 'a t

Similar to create d but here d is a function called to obtain a new default value for each distinct key. Useful if the default value is stateful.

val get : 'a t -> key -> 'a

Unfailing retrieval (possibly returns the default value). This will modify the table if the key wasn't present.

val set : 'a t -> key -> 'a -> unit

Replace the current binding for this key

val remove : 'a t -> key -> unit

Remove the binding for this key. If get tbl k is called later, the default value for the table will be returned

val to_seq : 'a t -> (key * 'a) sequence

Pairs of (elem, value) for all elements on which get was called

OCaml

Innovation. Community. Security.