diff options
| author | ppedrot | 2013-09-06 17:18:44 +0000 |
|---|---|---|
| committer | ppedrot | 2013-09-06 17:18:44 +0000 |
| commit | ba524ddfaabc80b31a439544de46c40366565ae8 (patch) | |
| tree | ff4350bc4ec7e225be1b6f9eeb5af83b45ab7f36 /lib/cStack.ml | |
| parent | ab7377de0a913ca6218bc7377fab33b8018f8f59 (diff) | |
Moving Searchstack to CStack, and normalizing names a bit.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16765 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib/cStack.ml')
| -rw-r--r-- | lib/cStack.ml | 35 |
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 |
