Stdlib.Pqueue(3) OCaml library Stdlib.Pqueue(3)

# [NAME](#NAME)

Stdlib.Pqueue - no description

# [Module](#Module)

Module Stdlib.Pqueue

# [Documentation](#Documentation)

Module **Pqueue**  
: **(module Stdlib\_\_Pqueue)**

*module type OrderedType =* **sig end**

Input signature of the functors **Pqueue.MakeMin** and **Pqueue.MakeMax** .

*module type Min =* **sig end**

Output signature of the functor **Pqueue.MakeMin** .

*module MakeMin :* **(E : OrderedType) -&gt; sig end**

Functor building an implementation of the min-priority queue structure given a totally ordered type for elements.

*module type Max =* **sig end**

Output signature of the functor **Pqueue.MakeMax** .

*module MakeMax :* **(E : OrderedType) -&gt; sig end**

Functor building an implementation of the max-priority queue structure given a totally ordered type for elements.

## [Polymorphic priority queues](#Polymorphic_priority_queues)

The following, more complex functors create polymorphic queues of type **'a t** , just like other polymorphic containers (lists, arrays...). They require a notion of "polymorphic elements" **'a**  
elt that can be compared without depending on the values of **'a** .

One usage scenario is when the user wants to pass priorities separately from the value stored in the queue. This is done by using pairs **priority * 'a** as elements.

```


      module Prio : OrderedType = ...




      module PrioQueue = Pqueue.MakeMinPoly(struct


        type 'a t = Prio.t * 'a


        let compare (p1, _) (p2, _) = Prio.compare p1 p2


      end)




      (* for example, we now have: *)


      PrioQueue.add: 'a PrioQueue.t -> Prio.t * 'a -> unit


      PrioQueue.min_elt: 'a PrioQueue.t -> (Prio.t * 'a) option


    
```

*module type OrderedPolyType =* **sig end**

Input signature of the functors **Pqueue.MakeMinPoly** and **Pqueue.MakeMaxPoly** .

*module type MinPoly =* **sig end**

Output signature of the functor **Pqueue.MakeMinPoly** .

*module MakeMinPoly :* **(E : OrderedPolyType) -&gt; sig end**

Functor building an implementation of min-priority queues given a totally ordered type for the elements.

*module type MaxPoly =* **sig end**

Output signature of the functor **Pqueue.MakeMaxPoly** .

*module MakeMaxPoly :* **(E : OrderedPolyType) -&gt; sig end**

Functor building an implementation of max-priority queues given a totally ordered type for the elements.

2026-10-23 OCamldoc

---

Document: Stdlib.Pqueue(3o) from ocaml 5.5.2-r0 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
