Changes between Version 14 and Version 15 of SetsCowan
 Timestamp:
 12/03/12 01:55:18 (4 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

SetsCowan
v14 v15 3 3 Sets and bags (multisets) are mutable collections that can contain any Scheme object. Integer sets are mutable collections that can contain nonnegative exact integers that are less than a maximum value specified when the integer set is created. Enumeration sets are mutable collections that can contain symbols chosen from a set of symbols represented by an enumeration type. 4 4 5 Sets and bags (multisets) are intended to be a thin veneer over hashtables, and integer sets are a thin veneer over b it vectors. In turn, enumeration sets are a thin veneer over integer sets. Consequently, the `member?`, `add!`, and `remove!` procedures are required to have an amortized cost of O(1).5 Sets and bags (multisets) are intended to be a thin veneer over hashtables, and integer sets are a thin veneer over bytevectors considered as sequences of bits. In turn, enumeration sets are a thin veneer over integer sets. Consequently, the `member?`, `add!`, and `remove!` procedures are required to have an amortized cost of O(1). 6 6 7 7 Sets, bags, integer sets, enumeration sets, and enumeration types are mutually disjoint, and disjoint from other types of Scheme objects. … … 9 9 == Set procedures == 10 10 11 It is an error to operate on sets with different equality procedures. 12 11 13 `(makeset `''=''`)` 12 14 … … 81 83 Returns `#t` if each ''set'' other than the last is a superset of the following ''set'', and `#f` otherwise. 82 84 83 `(setunion `''set,,1 '` `''otherset,,2'' ...`)`85 `(setunion `''set,,1,,''` `''set,,2,,'' ...`)` 84 86 85 87 Returns a newly allocated set that is the union of the ''sets''. It is an error if the sets do not have the same equality predicate. 86 88 87 `(setintersection `''set,,1 '` `''otherset,,2'' ...`)`89 `(setintersection `''set,,1,,''` `''set,,2,,'' ...`)` 88 90 89 91 Returns a newly allocated set that is the intersection of the ''sets''. It is an error if the sets do not have the same equality predicate. 90 92 91 `(setdifference `''set,,1 '` `''otherset,,2'' ...`)`92 93 Returns a newly allocated set that is the difference of the''sets''. It is an error if the sets do not have the same equality predicate.94 95 `(setxor `''set,,1 ''` `''set,,2''`)`96 97 Returns a newly allocated set that is the xor (symmetric difference) of ''set,,1 '' and ''set,,2,,''. It is an error if the sets do not have the same equality predicate.98 99 `(setunion! `''set,,1 '` `''otherset,,2'' ...`)`100 101 Mutates ''set '' to a newset that is the union of the ''sets''. It is an error if the sets do not have the same equality predicate.102 103 `(setintersection! `''set,,1 '` `''otherset,,2'' ...`)`104 105 Mutates ''set '' to a new set that is the intersection of 'the''sets''. It is an error if the sets do not have the same equality predicate.106 107 `(setdifference! `''set,,1 '` `''otherset,,2'' ...`)`108 109 Mutates ''set,,1 '' to a newset that is the difference of the ''sets''. It is an error if the sets do not have the same equality predicate.110 111 `(setxor! `''set,,1 ''` `''set,,2''`)`112 113 Mutates ''set '' to a new set that is the xor (symmetric difference) of ''set,,1'' and ''set,,2''. It is an error if the sets do not have the same equality predicate.93 `(setdifference `''set,,1,,''` `''set,,2,,'' ...`)` 94 95 Returns a newly allocated set that is the asymmetric difference of ''set,,1,,'' and the union of the other ''sets''. It is an error if the sets do not have the same equality predicate. 96 97 `(setxor `''set,,1,,''` `''set,,2,,''`)` 98 99 Returns a newly allocated set that is the xor (symmetric difference) of ''set,,1,,'' and ''set,,2,,''. 100 101 `(setunion! `''set,,1,,''` `''set,,2,,'' ...`)` 102 103 Mutates ''set,,1,,'' to a set that is the union of the ''sets''. It is an error if the sets do not have the same equality predicate. 104 105 `(setintersection! `''set,,1,,''` `set,,2,,'' ...`)` 106 107 Mutates ''set,,1,,'' to a set that is the asymmetric difference of ''set,,1,,'' and the union of the other ''sets''. It is an error if the sets do not have the same equality predicate. 108 109 `(setdifference! `''set,,1,,''` `''set,,2,,'' ...`)` 110 111 Mutates ''set,,1,,'' to a set that is the difference of the ''sets''. It is an error if the sets do not have the same equality predicate. 112 113 `(setxor! `''set,,1,,''` `''set,,2,,''`)` 114 115 Mutates ''set,,1,,'' to a new set that is the xor (symmetric difference) of ''set,,1,,'' and ''set,,2,,''. It is an error if the sets do not have the same equality predicate. 114 116 115 117 == Bag procedures == … … 121 123 Returns an exact integer representing the number of times that ''element'' appears in ''bag''. 122 124 125 `(bagincrement `''bag` `element` `count''`)` 126 127 `(bagdecrement `''bag` `element` `count''`)` 128 129 Increases or decreases the count of ''element'' in ''bag'' by the exact integer ''count''. 130 123 131 == Integer set procedures == 124 132