Module Assign5.DoubleListDequeue

type 'a t = 'a list * 'a list

The underlying type representing a double-ended queue.

val empty : 'a t

An empty dequeue.

val push_front : 'a -> 'a t -> 'a t

push_front x q is the dequeue gotten by prepending x to the front of q.

val pop_front : 'a t -> ('a * 'a t) option

pop_front q is

  • Some (x, r) where x is the first element of q and r is the remaining element of q;
  • None if q is empty.
val push_back : 'a -> 'a t -> 'a t

push_back x q is the dequeue gotten by appending x to the back of q.

val pop_back : 'a t -> ('a * 'a t) option

pop_back q is

  • Some (x, r) where x is the last element of q and r is the remaining element of q;
  • None if q is empty.
val to_list : 'a t -> 'a list

Converts a dequeue into a list with the same elements (in the same order).