diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-03-27 08:48:05 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-03-27 08:48:05 +0100 |
| commit | 830e7c5d27d161b91402414e6ecd49f1ed818bfb (patch) | |
| tree | 448864635d29b1ea66424cbb9e0816fbcf1e1907 /lib/splay/splay.mli | |
Initial commit
Diffstat (limited to 'lib/splay/splay.mli')
| -rw-r--r-- | lib/splay/splay.mli | 36 |
1 files changed, 36 insertions, 0 deletions
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 |
