Map.Using_comparator
Using_comparator
is a similar interface as the toplevel of Map
, except the functions take a ~comparator:('k, 'cmp) Comparator.t
, whereas the functions at the toplevel of Map
take a ('k, 'cmp) comparator
.
type nonrec ('k, +'v, 'cmp) t = ('k, 'v, 'cmp) t
val sexp_of_t :
('k -> Sexplib0.Sexp.t) ->
('v -> Sexplib0.Sexp.t) ->
('cmp -> Sexplib0.Sexp.t) ->
('k, 'v, 'cmp) t ->
Sexplib0.Sexp.t
val t_of_sexp_direct :
comparator:('k, 'cmp) Comparator.t ->
(Sexp.t -> 'k) ->
(Sexp.t -> 'v) ->
Sexp.t ->
('k, 'v, 'cmp) t
module Tree : sig ... end
val empty : comparator:('k, 'cmp) Comparator.t -> ('k, _, 'cmp) t
val singleton :
comparator:('k, 'cmp) Comparator.t ->
'k ->
'v ->
('k, 'v, 'cmp) t
val map_keys :
comparator:('k2, 'cmp2) Comparator.t ->
('k1, 'v, 'cmp1) t ->
f:('k1 -> 'k2) ->
[ `Ok of ('k2, 'v, 'cmp2) t | `Duplicate_key of 'k2 ]
val map_keys_exn :
comparator:('k2, 'cmp2) Comparator.t ->
('k1, 'v, 'cmp1) t ->
f:('k1 -> 'k2) ->
('k2, 'v, 'cmp2) t
val transpose_keys :
comparator:('k2, 'cmp2) Comparator.t ->
('k1, ('k2, 'a, 'cmp2) t, 'cmp1) t ->
('k2, ('k1, 'a, 'cmp1) t, 'cmp2) t
val of_sorted_array :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) array ->
('k, 'v, 'cmp) t Or_error.t
val of_sorted_array_unchecked :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) array ->
('k, 'v, 'cmp) t
val of_increasing_iterator_unchecked :
comparator:('k, 'cmp) Comparator.t ->
len:int ->
f:(int -> 'k * 'v) ->
('k, 'v, 'cmp) t
val of_alist :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) list ->
[ `Ok of ('k, 'v, 'cmp) t | `Duplicate_key of 'k ]
val of_alist_or_error :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) list ->
('k, 'v, 'cmp) t Or_error.t
val of_alist_exn :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) list ->
('k, 'v, 'cmp) t
val of_alist_multi :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) list ->
('k, 'v list, 'cmp) t
val of_alist_fold :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v1) list ->
init:'v2 ->
f:('v2 -> 'v1 -> 'v2) ->
('k, 'v2, 'cmp) t
val of_alist_reduce :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) list ->
f:('v -> 'v -> 'v) ->
('k, 'v, 'cmp) t
val of_increasing_sequence :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) Sequence.t ->
('k, 'v, 'cmp) t Or_error.t
val of_sequence :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) Sequence.t ->
[ `Ok of ('k, 'v, 'cmp) t | `Duplicate_key of 'k ]
val of_sequence_or_error :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) Sequence.t ->
('k, 'v, 'cmp) t Or_error.t
val of_sequence_exn :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) Sequence.t ->
('k, 'v, 'cmp) t
val of_sequence_multi :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) Sequence.t ->
('k, 'v list, 'cmp) t
val of_sequence_fold :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v1) Sequence.t ->
init:'v2 ->
f:('v2 -> 'v1 -> 'v2) ->
('k, 'v2, 'cmp) t
val of_sequence_reduce :
comparator:('k, 'cmp) Comparator.t ->
('k * 'v) Sequence.t ->
f:('v -> 'v -> 'v) ->
('k, 'v, 'cmp) t
val of_list_with_key :
comparator:('k, 'cmp) Comparator.t ->
'v list ->
get_key:('v -> 'k) ->
[ `Ok of ('k, 'v, 'cmp) t | `Duplicate_key of 'k ]
val of_list_with_key_or_error :
comparator:('k, 'cmp) Comparator.t ->
'v list ->
get_key:('v -> 'k) ->
('k, 'v, 'cmp) t Or_error.t
val of_list_with_key_exn :
comparator:('k, 'cmp) Comparator.t ->
'v list ->
get_key:('v -> 'k) ->
('k, 'v, 'cmp) t
val of_list_with_key_multi :
comparator:('k, 'cmp) Comparator.t ->
'v list ->
get_key:('v -> 'k) ->
('k, 'v list, 'cmp) t
val of_iteri :
comparator:('k, 'cmp) Comparator.t ->
iteri:(f:(key:'k -> data:'v -> unit) -> unit) ->
[ `Ok of ('k, 'v, 'cmp) t | `Duplicate_key of 'k ]
val of_iteri_exn :
comparator:('k, 'cmp) Comparator.t ->
iteri:(f:(key:'k -> data:'v -> unit) -> unit) ->
('k, 'v, 'cmp) t
val of_tree :
comparator:('k, 'cmp) Comparator.t ->
('k, 'v, 'cmp) Tree.t ->
('k, 'v, 'cmp) t
val invariants : ('k, 'v, 'cmp) t -> bool
val is_empty : (_, _, _) t -> bool
val length : (_, _, _) t -> int
val find_multi : ('k, 'v list, 'cmp) t -> 'k -> 'v list
val find : ('k, 'v, 'cmp) t -> 'k -> 'v option
val find_exn : ('k, 'v, 'cmp) t -> 'k -> 'v
val mem : ('k, _, 'cmp) t -> 'k -> bool
val iter_keys : ('k, _, _) t -> f:('k -> unit) -> unit
val iter : (_, 'v, _) t -> f:('v -> unit) -> unit
val iteri : ('k, 'v, _) t -> f:(key:'k -> data:'v -> unit) -> unit
val iteri_until :
('k, 'v, _) t ->
f:(key:'k -> data:'v -> Continue_or_stop.t) ->
Finished_or_unfinished.t
val fold :
('k, 'v, _) t ->
init:'acc ->
f:(key:'k -> data:'v -> 'acc -> 'acc) ->
'acc
val fold_until :
('k, 'v, _) t ->
init:'acc ->
f:(key:'k -> data:'v -> 'acc -> ('acc, 'final) Container.Continue_or_stop.t) ->
finish:('acc -> 'final) ->
'final
val fold_right :
('k, 'v, _) t ->
init:'acc ->
f:(key:'k -> data:'v -> 'acc -> 'acc) ->
'acc
val combine_errors : ('k, 'v Or_error.t, 'cmp) t -> ('k, 'v, 'cmp) t Or_error.t
val keys : ('k, _, _) t -> 'k list
val data : (_, 'v, _) t -> 'v list
val to_alist :
?key_order:[ `Increasing | `Decreasing ] ->
('k, 'v, _) t ->
('k * 'v) list
val symmetric_diff :
('k, 'v, 'cmp) t ->
('k, 'v, 'cmp) t ->
data_equal:('v -> 'v -> bool) ->
('k * [ `Left of 'v | `Right of 'v | `Unequal of 'v * 'v ]) Sequence.t
val min_elt : ('k, 'v, _) t -> ('k * 'v) option
val min_elt_exn : ('k, 'v, _) t -> 'k * 'v
val max_elt : ('k, 'v, _) t -> ('k * 'v) option
val max_elt_exn : ('k, 'v, _) t -> 'k * 'v
val for_all : ('k, 'v, _) t -> f:('v -> bool) -> bool
val for_alli : ('k, 'v, _) t -> f:(key:'k -> data:'v -> bool) -> bool
val exists : ('k, 'v, _) t -> f:('v -> bool) -> bool
val existsi : ('k, 'v, _) t -> f:(key:'k -> data:'v -> bool) -> bool
val count : ('k, 'v, _) t -> f:('v -> bool) -> int
val counti : ('k, 'v, _) t -> f:(key:'k -> data:'v -> bool) -> int
val subrange :
('k, 'v, 'cmp) t ->
lower_bound:'k Maybe_bound.t ->
upper_bound:'k Maybe_bound.t ->
('k, 'v, 'cmp) t
val fold_range_inclusive :
('k, 'v, 'cmp) t ->
min:'k ->
max:'k ->
init:'acc ->
f:(key:'k -> data:'v -> 'acc -> 'acc) ->
'acc
val range_to_alist : ('k, 'v, 'cmp) t -> min:'k -> max:'k -> ('k * 'v) list
val closest_key :
('k, 'v, 'cmp) t ->
[ `Greater_or_equal_to | `Greater_than | `Less_or_equal_to | `Less_than ] ->
'k ->
('k * 'v) option
val nth : ('k, 'v, 'cmp) t -> int -> ('k * 'v) option
val nth_exn : ('k, 'v, 'cmp) t -> int -> 'k * 'v
val rank : ('k, _, 'cmp) t -> 'k -> int option
val to_sequence :
?order:[ `Increasing_key | `Decreasing_key ] ->
?keys_greater_or_equal_to:'k ->
?keys_less_or_equal_to:'k ->
('k, 'v, 'cmp) t ->
('k * 'v) Sequence.t
val binary_search :
('k, 'v, 'cmp) t ->
compare:(key:'k -> data:'v -> 'key -> int) ->
Binary_searchable.Which_target_by_key.t ->
'key ->
('k * 'v) option
val binary_search_segmented :
('k, 'v, 'cmp) t ->
segment_of:(key:'k -> data:'v -> [ `Left | `Right ]) ->
Binary_searchable.Which_target_by_segment.t ->
('k * 'v) option
val binary_search_subrange :
('k, 'v, 'cmp) t ->
compare:(key:'k -> data:'v -> 'bound -> int) ->
lower_bound:'bound Maybe_bound.t ->
upper_bound:'bound Maybe_bound.t ->
('k, 'v, 'cmp) t
module Make_applicative_traversals
(A : Applicative.Lazy_applicative) :
sig ... end
val comparator : ('a, _, 'cmp) t -> ('a, 'cmp) Comparator.t
val hash_fold_direct :
'k Hash.folder ->
'v Hash.folder ->
('k, 'v, 'cmp) t Hash.folder
module Empty_without_value_restriction (K : Comparator.S1) : sig ... end
To get around the value restriction, apply the functor and include it. You can see an example of this in the Poly
submodule below.