module Heap: Heap.Removable
include Heap_intf.S
module Elt: sig
.. end
val add_removable : 'a t -> 'a -> 'a Elt.t
add_removable t v
adds v
to t
, returning a token that can be used to delete v
from t
in lg(n) amortized time.
val remove : 'a t -> 'a Elt.t -> unit
If t
and token
are mismatched then behavior is undefined. remove
may safely
be called on a token more than once. This doesn't free all the memory associated
with the Elt until some number of pop
operations later -- see Heap_intf for
details.
val update : 'a t -> 'a Elt.t -> 'a -> 'a Elt.t
update t token v
is shorthand for remove t token; add_removable t v
val find_elt : 'a t -> f:('a -> bool) -> 'a Elt.t option
find_elt t ~f
. If f
is true for some element in t
, return a Elt.t
for
that element. This operation is O(n).