This is documentation for version v0.9.0 of patricia-tree, but the latest version is v0.10.0.
Click here to redirect to the latest version.

Patricia Tree API - WithForeign

Operation with maps/set of different types

Parameters

module Map2 : BASE_MAP with type 'a key = 'a key

Signature

type ('map1, 'map2) polyinter_foreign = {
  1. f : 'a. 'a key -> ('a, 'map1) value -> ('a, 'map2) Map2.value -> ('a, 'map1) value;
}
val nonidempotent_inter : ('a, 'b) polyinter_foreign -> 'a t -> 'b Map2.t -> 'a t

Like BASE_MAP.idempotent_inter. Tries to preserve physical equality on the first argument when possible.

type ('map2, 'map1) polyfilter_map_foreign = {
  1. f : 'a. 'a key -> ('a, 'map2) Map2.value -> ('a, 'map1) value option;
}
val filter_map_no_share : ('map2, 'map1) polyfilter_map_foreign -> 'map2 Map2.t -> 'map1 t

Like BASE_MAP.filter_map_no_share, but allows to transform a foreigh map into the current one.

type ('map1, 'map2) polyupdate_multiple = {
  1. f : 'a. 'a key -> ('a, 'map1) value option -> ('a, 'map2) Map2.value -> ('a, 'map1) value option;
}
val update_multiple_from_foreign : 'b Map2.t -> ('a, 'b) polyupdate_multiple -> 'a t -> 'a t

This is equivalent to multiple calls to update, but more efficient. update_multiple_from_foreign m_from f m_to is the same as calling update k {f=fun v_to -> f.f k v_to v_from} m_to on all bindings (k, v_from) of m_from, i.e. update_multiple_from_foreign m_from f m_to calls f.f on every key of m_from, says if the corresponding value also exists in m_to, and adds or remove the element in m_to depending on the value of f.f. f.f is called in the order of Key.to_int. O(size(m_from) + size(m_to)) complexity.

type ('map1, 'map2) polyupdate_multiple_inter = {
  1. f : 'a. 'a key -> ('a, 'map1) value -> ('a, 'map2) Map2.value -> ('a, 'map1) value option;
}
val update_multiple_from_inter_with_foreign : 'b Map2.t -> ('a, 'b) polyupdate_multiple_inter -> 'a t -> 'a t

update_multiple_from_inter_with_foreign m_from f m_to is the same as update_multiple_from_foreign, except that instead of updating for all keys in m_from, it only updates for keys that are both in m_from and m_to.