aboutsummaryrefslogtreecommitdiff
path: root/lib/cStack.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cStack.ml')
-rw-r--r--lib/cStack.ml35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/cStack.ml b/lib/cStack.ml
new file mode 100644
index 0000000000..e0a3733f66
--- /dev/null
+++ b/lib/cStack.ml
@@ -0,0 +1,35 @@
+(************************************************************************)
+(* 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