Pqueue.Min(3)
β¨ NAME β¨
Pqueue.Min β this is the Pqueue.Min(3) page from the OCaml library, bestie. It's the output signature of the functor Pqueue.MakeMin.
π Module type π
Module type Pqueue.Min.
π Documentation π
Okay so here's the whole module type vibe:
Module type Min
= sig end
Output signature of the functor Pqueue.MakeMin .
πΈ Min-priority queues πΈ
type tβ The type of priority queues.type eltβ The type of priority queue elements.val create : unit -> tβ Return a new priority queue, initially empty.val length : t -> intβ Return the number of elements in a priority queue.val is_empty : t -> boolβis_empty qistrueiffqis empty, that is, ifflength q = 0.val add : t -> elt -> unitβadd q xadds the elementxin the priority queueq.val add_iter : t -> ((elt -> unit) -> 'x -> unit) -> 'x -> unitβadd_iter q iter xadds each element ofxto the end ofq. This isiter (add q) x.val min_elt : t -> elt optionβmin_elt qis an element ofqwith minimal priority orNoneif the queue is empty. The queue is not modified.val get_min_elt : t -> eltβget_min_elt qreturns an element ofqwith minimal priority, or raisesInvalid_argumentif the queue is empty. The queue is not modified.val pop_min : t -> elt optionβpop_min qremoves and returns an element in queueqwith minimal priority, or returnsNoneif the queue is empty.val remove_min : t -> unitβremove_min qremoves an element in queueqwith minimal priority. It does nothing ifqis empty.val clear : t -> unitβclear qremoves all elements fromq.val copy : t -> tβcopy qis a new priority queue with the same elementsqhas.
π¦ Conversions from other data structures π¦
val of_array : elt array -> tβof_array areturns a new priority queue containing the elements of arraya. Runs in linear time.val of_list : elt list -> tβof_list lreturns a new priority queue containing the elements of listl. Runs in linear time.val of_iter : ((elt -> unit) -> 'x -> unit) -> 'x -> tβof_iter iter xreturns a new priority queue containing the elements ofx, obtained fromiter.
For example, of_iter Seq.iter s returns a new priority queue containing all the elements of the sequence s (provided it is finite).
Runs in linear time (excluding the time spent in iter ).
π Iteration π
The order in which the elements of a priority queue are traversed is unspecified.
β οΈ It is a programming error to mutate a priority queue (by adding or removing elements) during an iteration of the queue. Such an error may be detected and signaled by the backing dynamic array implementation, but this is not guaranteed. no cap, that's the rule π
val iter_unordered : (elt -> unit) -> t -> unitβiter_unordered f qappliesfto all elements inq. The order in which the elements are passed tofis unspecified.
The behavior is not specified if the priority queue is modified by f during the iteration.
val fold_unordered : ('acc -> elt -> 'acc) -> 'acc -> t -> 'accβfold_unordered f accu qis(f (... (f (f accu x1) x2) ...) xn)wherex1,x2,...,xnare the elements ofq. The order in which the elements are passed tofis unspecified.
The behavior is not specified if the priority queue is modified by f during the iteration.
Signed, sealed, delivered by OCamldoc on 2026-06-22 β page Pqueue.Min(3) πβ¨
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms