X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=ptset.mli;h=27b63325d2b885621cf4a8d78f59272c76c0e693;hb=df5fdb22632be887ecd9f5c46a014e7e970148a2;hp=c36a08db87b223a1e78a86cd4d08514eb3fd08d7;hpb=d04661689691b4587cfc45a35e98604fcdc2b878;p=SXSI%2Fxpathcomp.git diff --git a/ptset.mli b/ptset.mli index c36a08d..27b6332 100644 --- a/ptset.mli +++ b/ptset.mli @@ -22,68 +22,70 @@ [Set]. The representation is unique and thus structural comparison can be performed on Patricia trees. *) -type t - -type elt = int - -val empty : t - -val is_empty : t -> bool - -val mem : int -> t -> bool - -val add : int -> t -> t - -val singleton : int -> t - -val remove : int -> t -> t - -val union : t -> t -> t - -val subset : t -> t -> bool - -val inter : t -> t -> t - -val diff : t -> t -> t - -val equal : t -> t -> bool - -val compare : t -> t -> int - -val elements : t -> int list - -val choose : t -> int - -val cardinal : t -> int - -val iter : (int -> unit) -> t -> unit - -val fold : (int -> 'a -> 'a) -> t -> 'a -> 'a - -val for_all : (int -> bool) -> t -> bool - -val exists : (int -> bool) -> t -> bool - -val filter : (int -> bool) -> t -> t - -val partition : (int -> bool) -> t -> t * t - -val split : int -> t -> t * bool * t - -(*s Warning: [min_elt] and [max_elt] are linear w.r.t. the size of the - set. In other words, [min_elt t] is barely more efficient than [fold - min t (choose t)]. *) +module type S = +sig + + type elt + + type 'a node + module rec Node : sig + include Hcons.S with type data = Data.t + end + and Data : sig + include + Hashtbl.HashedType with type t = Node.t node + end + type data = Data.t + type t = Node.t + + val empty : t + val is_empty : t -> bool + val mem : elt -> t -> bool + val add : elt -> t -> t + val singleton : elt -> t + val remove : elt -> t -> t + val union : t -> t -> t + val inter : t -> t -> t + val diff : t -> t -> t + val compare : t -> t -> int + val equal : t -> t -> bool + val subset : t -> t -> bool + val iter : (elt -> unit) -> t -> unit + val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a + val for_all : (elt -> bool) -> t -> bool + val exists : (elt -> bool) -> t -> bool + val filter : (elt -> bool) -> t -> t + val partition : (elt -> bool) -> t -> t * t + val cardinal : t -> int + val elements : t -> elt list + val min_elt : t -> elt + val max_elt : t -> elt + val choose : t -> elt + val split : elt -> t -> t * bool * t + (*s Additional functions not appearing in the signature [Set.S] from ocaml + standard library. *) + + (* [intersect u v] determines if sets [u] and [v] have a non-empty + intersection. *) + +val intersect : t -> t -> bool -val min_elt : t -> int -val max_elt : t -> int +val is_singleton : t -> bool +val mem_union : t -> t -> t +val hash : t -> int +val uid : t -> Uid.t +val uncons : t -> elt * t +val from_list : elt list -> t +val make : data -> t +val node : t -> data -(*s Additional functions not appearing in the signature [Set.S] from ocaml - standard library. *) +val with_id : Uid.t -> t +end -(* [intersect u v] determines if sets [u] and [v] have a non-empty - intersection. *) -val intersect : t -> t -> bool -val hash : t -> int +module Int : sig + include S with type elt = int + val print : Format.formatter -> t -> unit +end -val from_list : int list -> t +module Make ( H : Hcons.SA ) : S with type elt = H.t