(***********************************************************************) (* *) (* TAToo *) (* *) (* Kim Nguyen, LRI UMR8623 *) (* Université Paris-Sud & CNRS *) (* *) (* Copyright 2010-2013 Université Paris-Sud and Centre National de la *) (* Recherche Scientifique. All rights reserved. This file is *) (* distributed under the terms of the GNU Lesser General Public *) (* License, with the special exception on linking described in file *) (* ../LICENSE. *) (* *) (***********************************************************************) type node = Naive_tree.node type cell = { node : node; mutable next : cell } type t = { mutable length : int; mutable head : cell; mutable last : cell; } let rec nil = { node = Naive_tree.nil; next = nil } let create () = { length = 0; head = nil; last = nil } let iter f l = let rec loop c = if c != nil then begin f c.node; loop c.next end in loop l.head let length l = l.length let add n l = let ncell = { node = n; next = nil } in if l.last == nil then { length = 1; head = ncell; last = ncell } else let () = l.last.next <- ncell in { length = l.length + 1; head = l.head; last = ncell }