Pooled_hashtbl.Polytype nonrec ('a, 'b) t = ('a, 'b) tinclude Bin_prot.Binable.S2 with type ('a, 'b) t := ('a, 'b) tval bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t -> Bin_prot.Shape.tinclude sig ... endval bin_size_t : 'a 'b. ('a, 'b, ('a, 'b) t) Bin_prot.Size.sizer2val bin_write_t : 'a 'b. ('a, 'b, ('a, 'b) t) Bin_prot.Write.writer2val bin_read_t : 'a 'b. ('a, 'b, ('a, 'b) t) Bin_prot.Read.reader2val __bin_read_t__ : 'a 'b. ('a, 'b, ('a, 'b) t) Bin_prot.Read.vtag_reader2val bin_writer_t : 'a 'b. ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.writerval bin_reader_t : 'a 'b. ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.readerval bin_t : 'a 'b. ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.tinclude Base.Hashtbl.S_poly with type ('a, 'b) t := ('a, 'b) tinclude Sexplib0.Sexpable.S2 with type ('a, 'b) t := ('a, 'b) tval t_of_sexp :
'a 'b. (Sexplib0.Sexp.t -> 'a) ->
(Sexplib0.Sexp.t -> 'b) ->
Sexplib0.Sexp.t ->
('a, 'b) tval sexp_of_t :
'a 'b. ('a -> Sexplib0.Sexp.t) ->
('b -> Sexplib0.Sexp.t) ->
('a, 'b) t ->
Sexplib0.Sexp.tval t_sexp_grammar :
'a 'b. 'a Sexplib0.Sexp_grammar.t ->
'b Sexplib0.Sexp_grammar.t ->
('a, 'b) t Sexplib0.Sexp_grammar.t @@ portableval hashable : 'a Base.Hashable.tinclude Base.Invariant.S2 with type ('a, 'b) t := ('a, 'b) tval invariant : ('a -> unit) -> ('b -> unit) -> ('a, 'b) t -> unitval create : ?growth_allowed:bool -> ?size:int -> unit -> ('key, 'data) tCreates a new empty dictionary.
val of_alist :
?growth_allowed:bool ->
?size:int ->
('key key * 'data) list ->
[ `Ok of ('key, 'data) t | `Duplicate_key of 'key key ]Dictionary containing the given key/value pairs. Fails if there are duplicate keys.
val of_alist_report_all_dups :
?growth_allowed:bool ->
?size:int ->
('key key * 'data) list ->
[ `Ok of ('key, 'data) t | `Duplicate_keys of 'key key list ]Like of_alist. On failure, provides all duplicate keys instead of a single representative.
val of_alist_or_error :
?growth_allowed:bool ->
?size:int ->
('key key * 'data) list ->
('key, 'data) t Base.Or_error.tLike of_alist. Returns a Result.t.
Like of_alist. Raises on duplicates.
val of_alist_multi :
?growth_allowed:bool ->
?size:int ->
('key key * 'data) list ->
('key, 'data list) tProduces a dictionary mapping each key to a list of associated values.
val create_mapped :
?growth_allowed:bool ->
?size:int ->
get_key:('a -> 'key key) @ local ->
(get_data:('a -> 'data) @ local ->
('a list ->
[ `Ok of ('key, 'data) t | `Duplicate_keys of 'key key list ]) @ local) @ localLike of_alist. Consume a list of elements for which key/value pairs can be computed.
val create_with_key :
?growth_allowed:bool ->
?size:int ->
get_key:('data -> 'key key) @ local ->
('data list ->
[ `Ok of ('key, 'data) t | `Duplicate_keys of 'key key list ]) @ localLike of_alist. Consume values for which keys can be computed.
val create_with_key_or_error :
?growth_allowed:bool ->
?size:int ->
get_key:('data -> 'key key) @ local ->
('data list ->
('key, 'data) t Base.Or_error.t) @ localLike of_alist_or_error. Consume values for which keys can be computed.
val create_with_key_exn :
?growth_allowed:bool ->
?size:int ->
get_key:('data -> 'key key) @ local ->
('data list ->
('key, 'data) t) @ localLike of_alist_exn. Consume values for which keys can be computed.
val group :
?growth_allowed:bool ->
?size:int ->
get_key:('a -> 'key key) @ local ->
(get_data:('a -> 'data) @ local ->
(combine:('data -> ('data -> 'data) @ local) @ local ->
('a list ->
('key, 'data) t) @ local) @ local) @ localLike create_mapped. Multiple values for a key are combined rather than producing an error.
Attempting to modify (set, remove, etc.) the hashtable during iteration (fold, iter, iter_keys, iteri) will raise an exception.
val is_empty : (_, _) t -> boolWhether the dictionary is empty.
val length : (_, _) t -> intHow many key/value pairs the dictionary contains.
val data : (_, 'data) t -> 'data listAll values in the dictionary, in the same order as to_alist.
val clear : (_, _) t -> unitRemoves all key/value pairs from the dictionary.
Produces the current value, or absence thereof, for a given key.
Like find. Raises if there is no value for the given key.
Like find. Adds the value default () if none exists, then returns it.
Like find. Adds default key if no value exists.
val find_and_call :
'key 'data 'phantom 'c. ('key, 'data) t ->
'key key ->
if_found:('data -> 'c) @ local ->
(if_not_found:('key key -> 'c) @ local ->
'c) @ localLike find. Calls if_found data if a value exists, or if_not_found key otherwise. Avoids allocation Some.
val findi_and_call :
'key 'data 'phantom 'c. ('key, 'data) t ->
'key key ->
if_found:(key:'key key -> (data:'data -> 'c) @ local) @ local ->
(if_not_found:('key key -> 'c) @ local ->
'c) @ localLike findi. Calls if_found ~key ~data if a value exists.
Like find. Removes the value for key, if any, from the dictionary before returning it.
Adds a key/value pair for a key the dictionary does not contain, or reports a duplicate.
Adds or replaces a key/value pair in the dictionary.
Adds, replaces, or removes the value for a given key, depending on its current value or lack thereof.
Adds or replaces the value for a given key, depending on its current value or lack thereof.
Like update. Returns the new value.
Adds by to the value for key, default 0 if key is absent. May remove key if the result is 0, depending on remove_if_zero.
Subtracts by from the value for key, default 0 if key is absent. May remove key if the result is 0, depending on remove_if_zero.
val fold :
('key, 'data) t ->
init:'acc ->
f:(key:'key key -> (data:'data -> ('acc -> 'acc) @ local) @ local) @ local ->
'accCombines every value in the dictionary.
val for_all : (_, 'data) t -> f:('data -> bool) @ local -> boolWhether every value satisfies f.
Like for_all. The predicate may also depend on the associated key.
val exists : (_, 'data) t -> f:('data -> bool) @ local -> boolWhether at least one value satisfies f.
Like exists. The predicate may also depend on the associated key.
val count : (_, 'data) t -> f:('data -> bool) @ local -> intHow many values satisfy f.
Like count. The predicate may also depend on the associated key.
val iter : (_, 'data) t -> f:('data -> unit) @ local -> unitCalls f for every value.
Calls f for every key/value pair.
val mapi :
('key, 'data) t ->
f:(key:'key key -> (data:'data -> 'c) @ local) @ local ->
('key, 'c) tLike map. The transformation may also depend on the associated key.
val map_inplace : (_, 'data) t -> f:('data -> 'data) @ local -> unitLike map. Modifies the input.
val mapi_inplace :
('key, 'data) t ->
f:(key:'key key -> (data:'data -> 'data) @ local) @ local ->
unitLike mapi. Modifies the input.
Produces only those key/value pairs whose key satisfies f.
Produces only those key/value pairs whose value satisfies f.
val filteri :
('key, 'data) t ->
f:(key:'key key -> (data:'data -> bool) @ local) @ local ->
('key, 'data) tProduces only those key/value pairs which satisfy f.
Like filter_keys. Modifies the input.
val filter_inplace : (_, 'data) t -> f:('data -> bool) @ local -> unitLike filter. Modifies the input.
val filteri_inplace :
('key, 'data) t ->
f:(key:'key key -> (data:'data -> bool) @ local) @ local ->
unitLike filteri. Modifies the input.
Produces key/value pairs for which f produces Some.
val filter_mapi :
('key, 'data) t ->
f:(key:'key key -> (data:'data -> 'c option) @ local) @ local ->
('key, 'c) tLike filter_map. The new value may also depend on the associated key.
val filter_map_inplace :
(_, 'data) t ->
f:('data -> 'data option) @ local ->
unitLike filter_map. Modifies the input.
val filter_mapi_inplace :
('key, 'data) t ->
f:(key:'key key -> (data:'data -> 'data option) @ local) @ local ->
unitLike filter_mapi. Modifies the input.
val partition_tf :
('key, 'data) t ->
f:('data -> bool) @ local ->
('key, 'data) t * ('key, 'data) tSplits one dictionary into two. The first contains key/value pairs for which the value satisfies f. The second contains the remainder.
val partitioni_tf :
('key, 'data) t ->
f:(key:'key key -> (data:'data -> bool) @ local) @ local ->
('key, 'data) t * ('key, 'data) tLike partition_tf. The predicate may also depend on the associated key.
val partition_map :
('key, 'data) t ->
f:('data -> ('c, 'd) Base.Either.t) @ local ->
('key, 'c) t * ('key, 'd) tSplits one dictionary into two, corresponding respectively to First _ and Second _ results from f.
val partition_mapi :
('key, 'data) t ->
f:(key:'key key -> (data:'data -> ('c, 'd) Base.Either.t) @ local) @ local ->
('key, 'c) t * ('key, 'd) tLike partition_map. The split may also depend on the associated key.
val merge :
('key, 'data1) t ->
('key, 'data2) t ->
f:
(key:'key key ->
([ `Left of 'data1 | `Right of 'data2 | `Both of 'data1 * 'data2 ] ->
'data3 option) @ local) @ local ->
('key, 'data3) tMerges two dictionaries by fully traversing both. Not suitable for efficiently merging lists of dictionaries. See merge_into instead.
If the two dictionaries differ in their implementations, e.g. of hash or compare functions, those from the first argument are preferred.
val merge_into :
src:('key, 'data1) t ->
dst:('key, 'data2) t ->
f:
(key:'key key ->
('data1 ->
('data2 option ->
'data2 Base.Dictionary_mutable.Merge_into_action.t) @ local) @ local) @ local ->
unitMerges two dictionaries by traversing src and adding to dst. Computes the effect on dst of each key/value pair in src using f.
val sexp_of_key : ('a, _) t -> 'a key -> Sexplib0.Sexp.tval capacity : (_, _) t -> intval growth_allowed : (_, _) t -> boolChoose an arbitrary key/value pair of a hash table. Returns None if t is empty.
The choice is deterministic. Calling choose multiple times on the same table returns the same key/value pair, so long as the table is not mutated in between. Beyond determinism, no guarantees are made about how the choice is made. Expect bias toward certain hash values.
This hash bias can lead to degenerate performance in some cases, such as clearing a hash table using repeated choose and remove. At each iteration, finding the next element may have to scan farther from its initial hash value.
val choose_randomly :
?random_state:Base.Random.State.t ->
('a, 'b) t ->
('a key * 'b) optionChooses a random key/value pair of a hash table. Returns None if t is empty.
The choice is distributed uniformly across hash values, rather than across keys themselves. As a consequence, the closer the keys are to evenly spaced out in the table, the closer this function will be to a uniform choice of keys.
This function may be preferable to choose when nondeterministic choice is acceptable, and bias toward certain hash values is undesirable.
val choose_randomly_exn :
?random_state:Base.Random.State.t ->
('a, 'b) t ->
#('a key * 'b)Like choose_randomly. Raises if t is empty.
val find_or_null : 'a 'b. ('a, 'b) t -> 'a key -> 'b Basement.Or_null_shim.tfind_or_null returns This data if the key is found, Null if not.
val find_and_call1 :
'a 'b 'c 'd. ('a, 'b) t ->
'a key ->
a:'d ->
if_found:('b -> ('d -> 'c) @ local) @ local ->
(if_not_found:('a key -> ('d -> 'c) @ local) @ local ->
'c) @ localJust like find_and_call, but takes an extra argument which is passed to if_found and if_not_found, so that the client code can avoid allocating closures or using refs to pass this additional information. This function is only useful in code which tries to minimize heap allocation.
equal f t1 t2 and similar f t1 t2 both return true iff t1 and t2 have the same keys and for all keys k, f (find_exn t1 k) (find_exn t2 k). equal and similar only differ in their types.
add_multi t ~key ~data if key is present in the table then cons data on the list, otherwise add key with a single element list.
remove_multi t key updates the table, removing the head of the list bound to key. If the list has only one element (or is empty) then the binding is removed.
val validate :
name:('a key -> Base.String.t) ->
'b Validate.check ->
('a, 'b) t Validate.check