1 (***********************************************************************)
5 (* Kim Nguyen, LRI UMR8623 *)
6 (* Université Paris-Sud & CNRS *)
8 (* Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
9 (* Recherche Scientifique. All rights reserved. This file is *)
10 (* distributed under the terms of the GNU Lesser General Public *)
11 (* License, with the special exception on linking described in file *)
14 (***********************************************************************)
16 (** Type equipped with an equality and hash function.
17 If [equal a b] then [(hash a) = (hash b)]
19 module type HashedType =
23 (** [hash v] returns an integer in the range [ 0 - 2^30-1 ]
28 val equal : t -> t -> bool
32 (** Type equiped with a total ordering *)
33 module type OrderedType =
37 (** Total ordering on values of type [t]. [compare a b] returns a
38 negative number if [a] is strictly smaller than [b], a positive
39 number if [a] is strictly greater than [b] and 0 if [a] is equal
41 val compare : t -> t -> int
47 include HashedType with type t := t
48 include OrderedType with type t := t
51 (** Type equiped with a pretty-printer *)
52 module type Printable =
55 val print : Format.formatter -> t -> unit
58 (** Signature of a simple HashSet module *)
64 val add : t -> data -> unit
65 val remove : t -> data -> unit
66 val find : t -> data -> data
67 val find_all : t -> data -> data list
69 val mem : t -> data -> bool
72 (** Signature of simple Set module *)
78 val is_empty : t -> bool
79 val mem : elt -> t -> bool
80 val add : elt -> t -> t
81 val singleton : elt -> t
82 val remove : elt -> t -> t
83 val union : t -> t -> t
84 val inter : t -> t -> t
85 val diff : t -> t -> t
86 val compare : t -> t -> int
87 val equal : t -> t -> bool
88 val subset : t -> t -> bool
89 val iter : (elt -> unit) -> t -> unit
90 val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
91 val fold_left : (elt -> 'a -> 'a) -> t -> 'a -> 'a
92 val fold_right : (elt -> 'a -> 'a) -> t -> 'a -> 'a
93 val for_all : (elt -> bool) -> t -> bool
94 val exists : (elt -> bool) -> t -> bool
95 val filter : (elt -> bool) -> t -> t
96 val partition : (elt -> bool) -> t -> t * t
97 val cardinal : t -> int
98 val elements : t -> elt list
99 val min_elt : t -> elt
100 val max_elt : t -> elt
101 val choose : t -> elt
102 val split : elt -> t -> t * bool * t
103 val intersect : t -> t -> bool
104 val is_singleton : t -> bool
105 val from_list : elt list -> t