(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

open CSig

exception Empty = Stack.Empty

type 'a t = 'a list ref

let create () = ref []
let push x l = l := x :: !l
let pop l = match !l with [] -> raise Stack.Empty | x::xs -> l := xs; x
let top l = match !l with [] -> raise Stack.Empty | x::_ -> x
let find f l = List.find f !l
let find_map f l =
  let rec aux = function
  | [] -> raise Not_found
  | x :: xs -> match f x with None -> aux xs | Some i -> i
  in
  aux !l
let seek f accu l =
  let rec aux accu = function
    | [] -> raise Not_found
    | x :: xs -> match f accu x with Stop x -> x | Next i -> aux accu xs in
  aux accu !l
let is_empty l = match !l with [] -> true | _ -> false
let iter f l = List.iter f !l
let clear l = l := []
let length l = List.length !l
let to_list l = !l

(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

open CSig

exception Empty = Stack.Empty

type 'a t = 'a list ref

let create () = ref []
let push x l = l := x :: !l
let pop l = match !l with [] -> raise Stack.Empty | x::xs -> l := xs; x
let top l = match !l with [] -> raise Stack.Empty | x::_ -> x
let find f l = List.find f !l
let find_map f l =
  let rec aux = function
  | [] -> raise Not_found
  | x :: xs -> match f x with None -> aux xs | Some i -> i
  in
  aux !l
let seek f accu l =
  let rec aux accu = function
    | [] -> raise Not_found
    | x :: xs -> match f accu x with Stop x -> x | Next i -> aux i xs in
  aux accu !l
let is_empty l = match !l with [] -> true | _ -> false
let iter f l = List.iter f !l
let clear l = l := []
let length l = List.length !l
let to_list l = !l

Fix bug in CStack introduced by refactoring
Fix bug in CStack introduced by refactoring

Refactorings should be tested, right?

git-svn-id: 44dc50bdcc0f5d1a212c497508dc9452e0b35e2b@16768 85f007b7-540e-0410-9357-904b9bb8a0f7
