1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(*i $Id: heap.mli 6621 2005-01-21 17:24:37Z herbelin $ i*)
13
module type Ordered = sig
15
val compare : t -> t -> int
20
(* Type of functional heaps *)
23
(* Type of elements *)
29
(* [add x h] returns a new heap containing the elements of [h], plus [x];
30
complexity $O(log(n))$ *)
31
val add : elt -> t -> t
33
(* [maximum h] returns the maximum element of [h]; raises [EmptyHeap]
34
when [h] is empty; complexity $O(1)$ *)
35
val maximum : t -> elt
37
(* [remove h] returns a new heap containing the elements of [h], except
38
the maximum of [h]; raises [EmptyHeap] when [h] is empty;
39
complexity $O(log(n))$ *)
42
(* usual iterators and combinators; elements are presented in
44
val iter : (elt -> unit) -> t -> unit
46
val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
52
(*S Functional implementation. *)
54
module Functional(X: Ordered) : S with type elt=X.t