package grenier
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=e5362e6ad0e888526517415e78b9e8243bb0cc1b0c952201884148832ac4442f
sha512=4e2f16b52b3c2786a1b8e93156184fd69d448cea571ca839b6cb88ab73f380994d1561fe24c1523c43ed8fc42d2ac01b673a13b6151fff4af4f009923d3aaf37
doc/grenier.valmari/Partition/index.html
Module Partition
val create :
?partition:('n Strong.Finite.elt -> 'n Strong.Finite.elt -> int) ->
'n Strong.Finite.set ->
'n tcreate ?partition n create a fresh partitioning data structure for a set of cardinal n. If partition is not provided, the datastructure is initialized with a single subset that contains all elements. Otherwise, partition must be a total ordering function and elements that can be distinguished are put in different subsets.
val mark : 'n t -> 'n Strong.Finite.elt -> unitmark part elt marks the element elt as active. The datastructure manages an active set by marking a certain number of elements, and then applying an operation to all of them at once.
val split : 'n t -> unitPut marked elements in different sets. That is, each input set is split in two subsets one with the marked and one with the unmarked elements. Active set is reset after (no elements are marked).
val discard_unmarked : 'n t -> unitElements that are not marked are removed from the partition (they will be ignored by future operations). In practice, they are considered as belonging to set -1 (which can be observed by set_of function), and this -1 set is not counted by the set_count function. Active set is reset after (no elements are marked).
val discard : 'n t -> ('n Strong.Finite.elt -> bool) -> unitdiscard part f calls the function f for each element in the set and discard it if the function returns true. Active set must be empty before and is reset after (no elements are marked).
val set_count : 'n t -> intNumber of sets in the current partition
val set_of : 'n t -> 'n Strong.Finite.elt -> setset_of part elt returns the index of the set that contains element elt. Result is between 0 and set_of part - 1 unless the element has been discarded, in which case it is -1.
val choose : 'n t -> set -> 'n Strong.Finite.eltchoose part set returns an arbitrary element that belongs to set set. set must be between 0 and set_of part - 1.
val choose_opt : 'n t -> set -> 'n Strong.Finite.elt optionchoose part set returns an arbitrary element that belongs to set set. set must be between 0 and set_of part - 1.
val iter_elements : 'n t -> set -> ('n Strong.Finite.elt -> unit) -> unititer_elements part set f applies function f to each element that currently belongs to set set.
val iter_marked_elements :
'n t ->
set ->
('n Strong.Finite.elt -> unit) ->
unititer_marked_elements part set f applies function f to each element that currently belongs to set set and is marked.
val clear_marks : 'n t -> unitRemove all marks (reset the active set)
val is_first : 'n t -> 'n Strong.Finite.elt -> bool