/usr/lib/ocaml/reins/iterator.mli is in libreins-ocaml-dev 0.1a-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | (**************************************************************************)
(* The OCaml Reins Library *)
(* *)
(* Copyright 2007 Mike Furr. *)
(* All rights reserved. This file is distributed under the terms of the *)
(* GNU Lesser General Public License version 2.1 with the linking *)
(* exception given in the COPYING file. *)
(**************************************************************************)
(* CR SW: It seems pointless to have both and ml and an mli for a definition of
a module type. I'd just have the ml.
*)
(** The signature for an iterator over an arbitrary collection *)
module type S = sig
type 'a t
(** The type of iterators. An iterator serves as a pointer into
the middle of a collection. When possible, it always points
to a valid element in the collection (skipping over any
intermediate nodes that hold no value. *)
type 'a elt
(** The type of elements in the collection. *)
type 'a cursor
(** The type of the cursor that points into the collection *)
type 'a collection
(** The type of the collection *)
type direction
(** A type which guides the order of the traversal. Different
collections may support different directions. *)
type 'a traversal =
| Traverse_All
(** [Traverse_All] will visit every element in the collection. *)
| Traverse_If of ('a -> bool)
(** [Traverse_If f] will traverse only those elements for
which [f] returns true. *)
| Traverse_While of ('a -> bool)
(** [Traverse_While f] will traverse elements as long as [f]
is true. *)
(** This type defines the traversal strategy. It determines
which elements will be visited by the iterator.*)
val create : direction -> 'a elt traversal -> 'a collection -> 'a t
(** [create dir trav col] Create an iterator for the collection
[col] using the direction and traversal given. *)
val from_cursor : direction -> 'a elt traversal -> 'a cursor -> 'a t
(** [from_cursor dir trav curs] Create an iterator for the
collection starting at the cursor [curs]. The cursor need not
point to the beginning of the collection. If it does point to
an element, then this element will be the first element
visited by the iterator. *)
val value : 'a t -> 'a elt option
(** Return the element currently pointed to by the iterator. This
will return [None] only when the iterator has reached the end
of the collection. *)
val get_value : 'a t -> 'a elt
(** Similar to {!Iterator.S.value} except it throws the exception [Failure
"get_value"] if the iterator has reached the end of the
collection . *)
val at_end : 'a t -> bool
(** Returns true if the iterator has reached the end of the
collection as governed by the current traversal strategy. *)
val at_beg : 'a t -> bool
(** Returns true if the iterator is at the beginning of the
collection as governed by the current traversal strategy.
This is equivalent to {!Iterator.S.has_prev}. *)
val has_next : 'a t -> bool
(** Returns true if there is another element in the traversal
after the current element. *)
val next : 'a t -> 'a t
(** Advances the iterator to the next element in the collection.
If the iterator is at the end of the collection, it raises
[Failure "next"].
*)
val has_prev : 'a t -> bool
(** Returns true if there is another element that occurs before
the current element. Equivalent to {!Iterator.S.at_beg}. *)
val prev : 'a t -> 'a t
(** Advances the iterator to the previous element in the
collection. If the iterator is at the beginning of the
collection, it raises [Failure "prev"]. *)
val goto_beg : 'a t -> 'a t
(** Advance the iterator to the beginning of the collection as
governed by the traversal strategy *)
val goto_end : 'a t -> 'a t
(** Advance the iterator to the end of the collection as governed
by the traversal strategy *)
val flip : 'a t -> 'a t
(** Reverse the direction of the iterator. All elements that were
previously reachable by [next] are now reachable by [prev] and
vice versa. *)
val iter : ('a elt -> unit) -> 'a t -> unit
(** [iter f t] Apply [f] to each element in the collection that
satisfies the traversal strategy. If the iterator is not at
the beginning of the collection, the elements reachable by
{!Iterator.S.prev} will not be visited. *)
val fold : ('a -> 'b elt -> 'a) -> 'a -> 'b t -> 'a
(** [fold f acc t] Accumulates the result [acc] by applying [f acc
x] for each element [x] in the collection that satisfies the
traversal strategy. If the iterator is not at the beginning
of the collection, the elements reachable by
{!Iterator.S.prev} will not be visited. *)
end
|