package batteries
Install
Dune Dependency
Authors
Maintainers
Sources
md5=ea26b5c72e6731e59d856626049cca4d
sha512=55975b62c26f6db77433a3ac31f97af609fc6789bb62ac38b267249c78fd44ff37fe81901f1cf560857b9493a6046dd37b0d1c0234c66bd59e52843aac3ce6cb
doc/batteries.unthreaded/BatISet/index.html
Module BatISet
Source
DIET : Discrete Interval Encoding Trees
Sets of integers represented as ranges
This data structure is efficient for large sets of integers where many adjacent integers are all part of the set. This will have higher overhead for sets with lots of point elements, but will be much more efficient for sets containing mostly ranges.
the underlying representation is a balanced tree of ranges
This kind of set only holds ints
add_range lo hi t
adds the range of integers lo, hi
(including both endpoints) to the given set, returning a new set
remove_range lo hi t
removes a range of elements from the given set, returning a new set
Compute the union of two sets. This is the set whose elements are those elements in either input set.
Compute the intersection of two sets. This is the set whose elements are those in *both* of the input sets.
Compute the difference between two sets. This is the set of elements that are in the first but not in the second. Unlike union
and inter
, order matters here.
Create the complement of the given set - i.e. the set of all values not in the input set.
Compare two sets. It is not safe to use the polymorphic (<) and related functions to compare these sets, as the tree representation used can balance in multiple ways.
Test whether two sets are equal. It is not safe to use the polymorphic (=) on these sets, as the same set can have multiple representations depending on how it was built.
Same as compare
but returns BatOrd.Lt | BatOrd.Eq | BatOrd.Gt
instead of an int.
iter_range f t
calls f
once for each contiguous range of t
. The contiguous ranges of a set are sequences of adjacent integers all part of the set.
fold f t x0
returns the final result of merging each element of t
into x0
using merge function f
As fold, but operates on contiguous ranges
Tests whether a predicate applies to all elements of the set
Test whether some element of a set satisfies a predicate
Builds the subset of those elements that satisfy the predicate
partitions the input set into two sets with elements that satisfy the predicate and those that don't