1 (***********************************************************************)
5 (* Kim Nguyen, LRI UMR8623 *)
6 (* Université Paris-Sud & CNRS *)
8 (* Copyright 2010-2013 Université Paris-Sud and Centre National de la *)
9 (* Recherche Scientifique. All rights reserved. This file is *)
10 (* distributed under the terms of the GNU Lesser General Public *)
11 (* License, with the special exception on linking described in file *)
14 (***********************************************************************)
23 val create : unit -> t
24 val add : elem -> t -> unit
25 val push_front : elem -> t -> unit
26 val push_back : elem -> t -> unit
27 val iter : (elem -> unit) -> t -> unit
29 val is_empty : t -> bool
30 val head : t -> iterator
31 val last : t -> iterator
32 val next : iterator -> iterator
33 val value : iterator -> elem
34 val finished : iterator -> bool
38 module Make (E : sig type t end) =
43 type cell = { node : elem;
48 type t = { mutable length : int;
50 mutable last : cell; }
52 let rec nil = { node = Obj.magic ();
55 let create () = { length = 0;
61 if c != nil then begin
69 let length l = l.length
70 let is_empty l = l.head == nil
73 let ncell = { node = n;
76 if l.head == nil then begin
83 l.length <- l.length + 1
86 let push_back n l = add n l
88 let ncell = { node = n;
91 if l.head == nil then begin
97 l.length <- l.length + 1;
104 let finished i = i == nil
108 if finished i then l2 else begin
113 loop (create ()) (head l)