package containers

  1. Overview
  2. Docs

Extension to the standard Hashtbl

  • since 0.4
type 'a sequence = ('a -> unit) -> unit
type 'a eq = 'a -> 'a -> bool
type 'a hash = 'a -> int

Polymorphic tables

val get : ('a, 'b) Hashtbl.t -> 'a -> 'b option

Safe version of Hashtbl.find

val keys : ('a, 'b) Hashtbl.t -> 'a sequence

Iterate on keys (similar order as Hashtbl.iter)

val values : ('a, 'b) Hashtbl.t -> 'b sequence

Iterate on values in the table

val keys_list : ('a, 'b) Hashtbl.t -> 'a list

keys t is the list of keys in t.

  • since 0.8
val values_list : ('a, 'b) Hashtbl.t -> 'b list

values t is the list of values in t.

  • since 0.8
val map_list : ('a -> 'b -> 'c) -> ('a, 'b) Hashtbl.t -> 'c list

Map on a hashtable's items, collect into a list

val to_seq : ('a, 'b) Hashtbl.t -> ('a * 'b) sequence

Iterate on bindings in the table

val of_seq : ('a * 'b) sequence -> ('a, 'b) Hashtbl.t

From the given bindings, added in order

val to_list : ('a, 'b) Hashtbl.t -> ('a * 'b) list

List of bindings (order unspecified)

val of_list : ('a * 'b) list -> ('a, 'b) Hashtbl.t

From the given list of bindings, added in order

Functor

module type S = sig ... end
module Make (X : Hashtbl.HashedType) : S with type key = X.t and type 'a t = 'a Hashtbl.Make(X).t

Default Table

A table with a default element for keys that were never added.

module type DEFAULT = sig ... end
module MakeDefault (X : Hashtbl.HashedType) : DEFAULT with type key = X.t

Count occurrences using a Hashtbl

module type COUNTER = sig ... end
module MakeCounter (X : Hashtbl.HashedType) : COUNTER with type elt = X.t
OCaml

Innovation. Community. Security.