aboutsummaryrefslogtreecommitdiffhomepage
path: root/clib/deque.mli
blob: 1c03c384dfcd4b7c7483d0c199de93544f5d8852 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)

(** * Purely functional, double-ended queues *)

(** This module implements the banker's deque, from Okasaki. Most operations are
    amortized O(1). *)

type +'a t

exception Empty

(** {5 Constructor} *)

val empty : 'a t

(** The empty deque. *)

(** {5 Left-side operations} *)

val lcons : 'a -> 'a t -> 'a t
(** Pushes an element on the left side of the deque. *)

val lhd : 'a t -> 'a
(** Returns the leftmost element in the deque. Raises [Empty] when empty. *)

val ltl : 'a t -> 'a t
(** Returns the left-tail of the deque. Raises [Empty] when empty. *)

(** {5 Right-side operations} *)

val rcons : 'a -> 'a t -> 'a t
(** Same as [lcons] but on the right side. *)

val rhd : 'a t -> 'a
(** Same as [lhd] but on the right side. *)

val rtl : 'a t -> 'a t
(** Same as [ltl] but on the right side. *)

(** {5 Operations} *)

val rev : 'a t -> 'a t
(** Reverse deque. *)

val length : 'a t -> int
(** Length of a deque. *)

val is_empty : 'a t -> bool
(** Emptyness of a deque. *)

val filter : ('a -> bool) -> 'a t -> 'a t
(** Filters the deque *)