module Dllist: sig end
This data structure is not thread safe.
See also testing/test_dllist.ml
for simple examples of how to use this
module.
exception Empty
exception OutOfBounds
type 'a
t
'a
.type 'a
cons
'a
.val deref : 'a cons -> 'a
val create : unit -> 'a t
val first : 'a t -> 'a cons
first d
returns the first cell in the dllist d
. Raise Empty
if the dllist is empty.val last : 'a t -> 'a cons
last d
returns the last cell in the dllist d
. Raise Empty
if
the dllist is empty.val next : 'a cons -> 'a cons
next c
returns the next cell in the dllist in which c
is
contained. Returns OutOfBounds
if c
is the last cell.val prev : 'a cons -> 'a cons
prev c
returns the previous cell in the dllist in which c
is
contained. Returns OutOfBounds
if c
is the first cell.val insert_end : 'a -> 'a t -> 'a cons
insert_end v q
inserts a new cell with value v
at the end of
the dllist q
, and returns the newly created cell.val insert_before : 'a -> 'a cons -> 'a cons
insert_before v c
inserts a new cell with value v
just before
cell c
in the dllist in which c
exists, and returns the newly
created cell.exception Cons_already_free
val remove : 'a cons -> unit
remove c
removes the cell c
from dllist where it exists.val count : 'a t -> int
count q
returns the number of cells in the dllist q
.val to_list : 'a t -> 'a cons list
val iter : ('a -> unit) -> 'a t -> unit
iter f q
applies f e
for each entry e
of the dllist
q
.