diff options
| author | gareuselesinge | 2013-09-30 16:09:52 +0000 |
|---|---|---|
| committer | gareuselesinge | 2013-09-30 16:09:52 +0000 |
| commit | 5af66c65b3a97074b95ed5434b032a651b570e98 (patch) | |
| tree | 00f55ff802a3148c59a631bf05487b206b1b885b /lib/cStack.mli | |
| parent | eea45f9567a23db9efbff0764557dda5b1e51cd2 (diff) | |
lib/cstack: various improvements
- renaming reflecting the semantic of functions
- ability to edit the stack at the top of a _focused_zone_
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16811 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib/cStack.mli')
| -rw-r--r-- | lib/cStack.mli | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/lib/cStack.mli b/lib/cStack.mli index edca854488..78d2563a17 100644 --- a/lib/cStack.mli +++ b/lib/cStack.mli @@ -8,8 +8,6 @@ (** Extended interface for OCaml stacks. *) -open CSig - type 'a t exception Empty @@ -25,14 +23,6 @@ val find : ('a -> bool) -> 'a t -> 'a (** Find the first element satisfying the predicate. @raise Not_found it there is none. *) -val find_map : ('a -> 'b option) -> 'a t -> 'b -(** Find the first element that returns [Some _]. - @raise Not_found it there is none. *) - -val seek : ('c -> 'a -> ('b, 'c) seek) -> 'c -> 'a t -> 'b -(** Find the first element that returns [Some _]. - @raise Not_found it there is none. *) - val is_empty : 'a t -> bool (** Whether a stack is empty. *) @@ -56,3 +46,33 @@ val top : 'a t -> 'a val to_list : 'a t -> 'a list (** Convert to a list. *) +val find_map : ('a -> 'b option) -> 'a t -> 'b +(** Find the first element that returns [Some _]. + @raise Not_found it there is none. *) + +type ('b, 'c) seek = ('b, 'c) CSig.seek = Stop of 'b | Next of 'c + +(** [seek f acc s] acts like [List.fold_left f acc s] while [f] returns + [Next acc']; it stops returning [b] as soon as [f] returns [Stop b]. + The stack is traversed from the top and is not altered. + @raise Not_found it there is none. *) +val fold_until : ('c -> 'a -> ('b, 'c) seek) -> 'c -> 'a t -> 'b + +(** After [focus s c1 c2] the top of [s] is the topmost element [x] such that + [c1 x] is [true] and the bottom is the first element [y] following [x] + such that [c2 y] is [true]. After a focus push/pop/top/fold_until + only use the focused part. + @raise Invalid_argument "CStack.focus" if there is no such [x] and [y] *) +val focus : 'a t -> cond_top:('a -> bool) -> cond_bot:('a -> bool) -> unit + +(** Undoes a [focus]. + @raise Invalid_argument "CStack.unfocus" if the stack is not focused *) +val unfocus : 'a t -> unit + +(** Is the stack focused *) +val focused : 'a t -> bool + +(** Returns [top, s, bot] where [top @ s @ bot] is the full stack, and [s] + the focused part *) +val to_lists : 'a t -> 'a list * 'a list * 'a list + |
