Initial import
[hcoop/zz_old/domtool.git] / src / smlnj-lib / ord-set-sig.sml
1 (* ordset-sig.sml
2 *
3 * COPYRIGHT (c) 1993 by AT&T Bell Laboratories. See COPYRIGHT file for details.
4 *
5 * Signature for a set of values with an order relation.
6 *)
7
8 signature ORD_SET =
9 sig
10
11 structure Key : ORD_KEY
12
13 type item = Key.ord_key
14 type set
15
16 val empty : set
17 (* The empty set *)
18
19 val singleton : item -> set
20 (* Create a singleton set *)
21
22 val add : set * item -> set
23 val add' : (item * set) -> set
24 (* Insert an item. *)
25
26 val addList : set * item list -> set
27 (* Insert items from list. *)
28
29 val delete : set * item -> set
30 (* Remove an item. Raise NotFound if not found. *)
31
32 val member : set * item -> bool
33 (* Return true if and only if item is an element in the set *)
34
35 val isEmpty : set -> bool
36 (* Return true if and only if the set is empty *)
37
38 val equal : (set * set) -> bool
39 (* Return true if and only if the two sets are equal *)
40
41 val compare : (set * set) -> order
42 (* does a lexical comparison of two sets *)
43
44 val isSubset : (set * set) -> bool
45 (* Return true if and only if the first set is a subset of the second *)
46
47 val numItems : set -> int
48 (* Return the number of items in the table *)
49
50 val listItems : set -> item list
51 (* Return an ordered list of the items in the set *)
52
53 val union : set * set -> set
54 (* Union *)
55
56 val intersection : set * set -> set
57 (* Intersection *)
58
59 val difference : set * set -> set
60 (* Difference *)
61
62 val map : (item -> item) -> set -> set
63 (* Create a new set by applying a map function to the elements
64 * of the set.
65 *)
66
67 val app : (item -> unit) -> set -> unit
68 (* Apply a function to the entries of the set
69 * in increasing order
70 *)
71
72 val foldl : (item * 'b -> 'b) -> 'b -> set -> 'b
73 (* Apply a folding function to the entries of the set
74 * in increasing order
75 *)
76
77 val foldr : (item * 'b -> 'b) -> 'b -> set -> 'b
78 (* Apply a folding function to the entries of the set
79 * in decreasing order
80 *)
81
82 val partition : (item -> bool) -> set -> (set * set)
83
84 val filter : (item -> bool) -> set -> set
85
86 val exists : (item -> bool) -> set -> bool
87
88 val find : (item -> bool) -> set -> item option
89
90 end (* ORD_SET *)