package patricia-tree
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=88f2c7c92d609e5a92d2b6242d1d355c85273200f0a1e7e9eab858c4ded09650
sha512=89083fb58c894f5af255172c7bf43e4871bc31afcf86c4cd622773984cd8550ea1e61b31c676c431b6ba5eaf4b4e562ffeaa0cfba893121d783b5cceb7a55623
doc/patricia-tree/PatriciaTree/MakeSet/index.html
Module PatriciaTree.MakeSetSource
Create a Patricia tree based set, analogous to the standard library's Set.Make
Parameters
Signature
Underlying basemap, for cross map/set operations
Basic functions
mem elt set is true if elt is contained in set, O(log(n)) complexity.
add elt set adds element elt to the set. Preserves physical equality if elt was already present. O(log(n)) complexity.
cardinal set is the size of the set (number of elements), O(n) complexity.
is_singleton set is Some (Any elt) if set is singleton elt and None otherwise.
remove elt set returns a set containing all elements of set except elt. Returns a value physically equal to set if elt is not present.
The minimal element (according to the unsigned order on KEY.to_int) if non empty.
The maximal element (according to the unsigned order on KEY.to_int) if non empty.
pop_unsigned_minimum s is Some (elt, s') where elt = unsigned_min_elt s and s' = remove elt s if s is non empty. Uses the unsigned order on KEY.to_int.
pop_unsigned_maximum s is Some (elt, s') where elt = unsigned_max_elt s and s' = remove elt s if s is non empty. Uses the unsigned order on KEY.to_int.
Iterators
iter f set calls f on all elements of set, in the unsigned order of KEY.to_int.
filter f set is the subset of set that only contains the elements that satisfy f. f is called in the unsigned order of KEY.to_int.
for_all f set is true if f is true on all elements of set. Short-circuits on first false. f is called in the unsigned order of KEY.to_int.
fold f set acc returns f elt_n (... (f elt_1 acc) ...), where elt_1, ..., elt_n are the elements of set, in increasing unsigned order of KEY.to_int
split elt set returns s_lt, present, s_gt where s_lt contains all elements of set smaller than elt, s_gt all those greater than elt, and present is true if elt is in set. Uses the unsigned order on KEY.to_int.
val pretty :
?pp_sep:(Format.formatter -> unit -> unit) ->
(Format.formatter -> elt -> unit) ->
Format.formatter ->
t ->
unitPretty prints the set, pp_sep is called once between each element, it defaults to Format.pp_print_cut
Functions on pairs of sets
union a b is the set union of a and b, i.e. the set containing all elements that are either in a or b.
inter a b is the set intersection of a and b, i.e. the set containing all elements that are in both a or b.
compare s1 s2 is an order on setss. s1 and s2 are equal if they contain the same bindings (compare by KEY.to_int). s1 is strictly smaller than s2 if the first difference (in the order of KEY.to_int) is an element that appears in s2 but not in s1.
min_elt_inter s1 s2 is unsigned_min_elt of inter s1 s2, but faster as it does not require computing the whole intersection. Returns None when the intersection is empty.
max_elt_inter s1 s2 is unsigned_max_elt of inter s1 s2, but faster as it does not require computing the whole intersection. Returns None when the intersection is empty.
Conversion functions
to_seq st iterates the whole set, in increasing unsigned order of KEY.to_int
to_rev_seq st iterates the whole set, in decreasing unsigned order of KEY.to_int
add_seq s st adds all elements of the sequence s to st in order.
to_list s returns the elements of s as a list, in increasing unsigned order of KEY.to_int