(* Listes doublement chaînées mutables *) (* $Id: ldcm.ml,v 1.1 2003/01/12 15:33:00 berke Exp $ *) (* Par Berke Durak *) (* 08112000 *) type 'a cldcm = { mutable etiq: 'a; mutable succ: 'a cldcm option; mutable pred: 'a cldcm option; } and 'a ldcm = { mutable prem: 'a cldcm option; mutable dern: 'a cldcm option; } let creer_ldcm () = { prem = None; dern = None } let premier_ldcm l = match l.prem with | None -> None | Some x -> Some x.etiq let ajouter_fin_ldcm l e = let c = { etiq = e; succ = None; pred = l.dern } in begin match l.dern with | None -> l.prem <- Some c; l.dern <- Some c | Some x -> l.dern <- Some c; x.succ <- Some c end; c let enlever_ldcm l e = match (e.pred,e.succ) with | (None,None) -> l.prem <- None; l.dern <- None | (Some x, None) -> x.succ <- None; l.dern <- Some x | (None, Some x) -> l.prem <- Some x; x.pred <- None | (Some x, Some y) -> x.succ <- Some y; y.pred <- Some x