diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2018-07-29 19:01:24 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2018-07-29 19:01:24 +0200 |
commit | a0ea857685804735d60f19a166274745d8785e62 (patch) | |
tree | d0be2c5809d17a9afaf3af255f51a8ce7bc2fdaf /src/tree | |
parent | 2d52075c1d0f1b893d16f3e567fed5bc1e520be7 (diff) |
Update the traversing sheet function
Diffstat (limited to 'src/tree')
-rw-r--r-- | src/tree/splay.ml | 5 | ||||
-rwxr-xr-x | src/tree/splay.mli | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/tree/splay.ml b/src/tree/splay.ml index de7d441..dd1f65d 100644 --- a/src/tree/splay.ml +++ b/src/tree/splay.ml @@ -180,6 +180,11 @@ module Make (El : KEY) = struct _fold [] init !t end + let choose (T tree) = begin match (_subtree_minimum !tree) with + | Leaf -> raise Not_found + | Node (left, (key, value), right) -> C (key, value) + end + let repr formatter (T t) = begin let repr_edge from formatter dest = begin diff --git a/src/tree/splay.mli b/src/tree/splay.mli index a640075..60d067b 100755 --- a/src/tree/splay.mli +++ b/src/tree/splay.mli @@ -48,6 +48,11 @@ module Make (El : KEY) : sig val fold: ('a -> container -> 'a) -> 'a -> t -> 'a
+ (** Return one element of the given tree, or raise Not_found if the tree is
+ empty. Which element is chosen is unspecified, but equal elements will be
+ chosen for equal trees. *)
+ val choose: t -> container
+
(** Represent the content in dot syntax *)
val repr: Format.formatter -> t -> unit
|