From 830e7c5d27d161b91402414e6ecd49f1ed818bfb Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 27 Mar 2026 08:48:05 +0100 Subject: Initial commit --- lib/splay/splay.mli | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 lib/splay/splay.mli (limited to 'lib/splay/splay.mli') diff --git a/lib/splay/splay.mli b/lib/splay/splay.mli new file mode 100644 index 0000000..f484651 --- /dev/null +++ b/lib/splay/splay.mli @@ -0,0 +1,36 @@ +module type KEY = sig + type t + + val compare : t -> t -> int + val pp : Format.formatter -> t -> unit +end + +module Make (El : KEY) : sig + type 'a t + + val empty : unit -> 'a t + (** Create an empty tree *) + + val isEmpty : 'a t -> bool + + val find : El.t -> 'a t -> 'a option + (** Return the element in the tree with the given key *) + + val add : El.t -> 'a -> 'a t -> 'a t + (** Add one element in the tree, if the key is already present, the associated + element is replaced. *) + + val member : El.t -> 'a t -> bool + (** Check if the key exists *) + + val remove : El.t -> 'a t -> 'a t + val fold : ('a -> El.t * 'b -> 'a) -> 'a -> 'b t -> 'a + + val choose : 'a t -> (El.t * 'a) option + (** 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 pp : Format.formatter -> 'a t -> unit + (** Represent the content in dot syntax *) +end -- cgit v1.2.3