package orsetto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

A functor to create a PQueue module.

Parameters

Signature

type +'a t

The priority queue type.

val nil : 'a t

The empty priority queue.

val one : (K.t * 'a) -> 'a t

Use one kv to create a priority queue containing the single priority-value pair kv.

val empty : 'a t -> bool

Use empty q to test whether q is empty.

val size : 'a t -> int

Use size q to compute the number of elements in q. Runs in O(n) time and O(log N) space.

val head : 'a t -> K.t * 'a

Use head q to obtain the key-value pair on the top of q. Raises Not_found if q is empty.

val tail : 'a t -> 'a t

Use tail q to obtain the priority queue produced by discarding the element at the top of q. If q is the empty queue, then the empty queue is returned.

val pop : 'a t -> ((K.t * 'a) * 'a t) option

Use pop q to obtain the head and the tail of a priority queue q in one operation. Returns None if q is empty.

val put : (K.t * 'a) -> 'a t -> 'a t

Use put kv q to obtain a new priority queue that is the result of inserting the key-value pair kv into q.

val merge : 'a t -> 'a t -> 'a t

Use merge q1 q2 to obtain a new priority queue that is the result of merging all the elements of q1 and q2 into a single queue.

val of_seq : (K.t * 'a) Seq.t -> 'a t

Use of_seq s to construct a priority queue from a sequence of key-value pairs. Evaluates the whole sequence. Runs in O(n) time and O(1) space.

val to_seq : 'a t -> (K.t * 'a) Seq.t

Use to_seq q to produce a sequence of the key-value pairs in q from top to bottom.

OCaml

Innovation. Community. Security.