extlib
Library
Module
Module type
Parameter
Class
Class type
type ('a, 'b) t = ( 'a, 'b ) Hashtbl.t
The type of a hashtable.
New Functions
val exists : ( 'a, 'b ) t -> 'a -> bool
exists h k
returns true is at least one item with key k
is found in the hashtable.
Return an enumeration of all the keys of a hashtable. If the key is in the Hashtable multiple times, all occurrences will be returned.
Return an enumeration of (key,value) pairs of a hashtable.
val find_default : ( 'a, 'b ) t -> 'a -> 'b -> 'b
Find a binding for the key, and return a default value if not found
val find_opt : ( 'a, 'b ) Hashtbl.t -> 'a -> 'b option
Find a binding for the key, or return None
if no value is found
val find_option : ( 'a, 'b ) Hashtbl.t -> 'a -> 'b option
compatibility, use find_opt
val remove_all : ( 'a, 'b ) t -> 'a -> unit
Remove all bindings for the given key
map f x
creates a new hashtable with the same keys as x
, but with the function f
applied to all the values
val length : ( 'a, 'b ) t -> int
Return the number of elements inserted into the Hashtbl (including duplicates)
val reset : ( 'a, 'b ) t -> unit
type statistics = Hashtbl.statistics = {
num_bindings : int; |
num_buckets : int; |
max_bucket_length : int; |
bucket_histogram : int array; |
}
val stats : ( 'a, 'b ) t -> statistics
val filter_map_inplace : ( 'a -> 'b -> 'b option ) -> ( 'a, 'b ) t -> unit
Older Functions
Please refer to the Ocaml Manual for documentation of these functions.
val create : ?random:bool -> int -> ( 'a, 'b ) t
val clear : ( 'a, 'b ) t -> unit
val add : ( 'a, 'b ) t -> 'a -> 'b -> unit
val find : ( 'a, 'b ) t -> 'a -> 'b
val find_all : ( 'a, 'b ) t -> 'a -> 'b list
val mem : ( 'a, 'b ) t -> 'a -> bool
val remove : ( 'a, 'b ) t -> 'a -> unit
val replace : ( 'a, 'b ) t -> 'a -> 'b -> unit
val iter : ( 'a -> 'b -> unit ) -> ( 'a, 'b ) t -> unit
val fold : ( 'a -> 'b -> 'c -> 'c ) -> ( 'a, 'b ) t -> 'c -> 'c
*_seq
functions were introduced in OCaml 4.07.0, and are _not_ implemented in extlib for older OCaml versions
Functor interface forwards directly to stdlib implementation (i.e. no enum functions)
module type HashedType = Hashtbl.HashedType
module type S = Hashtbl.S
module Make = Hashtbl.Make
module type SeededHashedType = Hashtbl.SeededHashedType
module type SeededS = Hashtbl.SeededS
module MakeSeeded = Hashtbl.MakeSeeded