package ocaml-solo5
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=47876167068345542f49279e8fd28896
sha512=272081ec51a6ed69c08e4e8fa64fee3df53fd84c66c0c07a653891c88b342cf74553e1c95711e4fbc18922c899a3448a649f3bd9858f8d89cae834ad2b67fffb
doc/stdlib/Stdlib/Pqueue/MakeMin/index.html
Module Pqueue.MakeMinSource
Functor building an implementation of the min-priority queue structure given a totally ordered type for elements.
Parameters
module E : OrderedTypeSignature
Min-priority queues
The type of priority queues.
add_iter q iter x adds each element of x to the end of q. This is iter (add q) x.
min_elt q is an element of q with minimal priority or None if the queue is empty. The queue is not modified.
get_min_elt q returns an element of q with minimal priority, or raises Stdlib.Invalid_argument if the queue is empty. The queue is not modified.
pop_min q removes and returns an element in queue q with minimal priority, or returns None if the queue is empty.
remove_min q removes an element in queue q with minimal priority. It does nothing if q is empty.
Conversions from other data structures
of_array a returns a new priority queue containing the elements of array a. Runs in linear time.
of_list l returns a new priority queue containing the elements of list l. Runs in linear time.
of_iter iter x returns a new priority queue containing the elements of x, obtained from iter.
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.
iter_unordered f q applies f to all elements in q. The order in which the elements are passed to f is unspecified.
The behavior is not specified if the priority queue is modified by f during the iteration.
fold_unordered f accu q is (f (... (f (f accu x1) x2) ...) xn) where x1,x2,...,xn are the elements of q. The order in which the elements are passed to f is unspecified.
The behavior is not specified if the priority queue is modified by f during the iteration.