Clean up set operations
authorStefan Vogel <sv@exept.de>
Thu, 03 Apr 2003 10:45:30 +0200
changeset 7169 74576ccad3c0
parent 7168 e5400f46d437
child 7170 19558aa463e0
Clean up set operations
Collection.st
Set.st
--- a/Collection.st	Thu Apr 03 10:07:54 2003 +0200
+++ b/Collection.st	Thu Apr 03 10:45:30 2003 +0200
@@ -2285,25 +2285,9 @@
 
 !Collection methodsFor:'set operations'!
 
-+ aCollection
-    "return a new set containing all elements of the receiver 
-     plus those of the argument collection"
-
-    |newCollection|
-
-    newCollection := self speciesForAdding new.
-    newCollection addAll:self.
-    newCollection addAll:aCollection.
-    ^ newCollection
-
-    "
-     #(0 2 4 6 8)  + #(1 3 5 7)   
-    "
-!
-
-- aCollection
+\ aCollection
     "return a new set containing all elements of the receiver, which are
-     NOT also contained in the argument collection
+     NOT also contained in the aCollection
      For large collections you better use a Set for aCollection"
 
 
@@ -2318,9 +2302,9 @@
     ^ newCollection
 
     "
-     #(0 1 2 3 4 5 6 7 8 9) - #(1 2 3) asSet  
-     #(0 1 2 3 4 5 6 7 8 9) - #(1 2 3)
-    ('hello' - 'l') asString
+     #(0 1 2 3 4 5 6 7 8 9) \ #(1 2 3) asSet  
+     #(0 1 2 3 4 5 6 7 8 9) \ #(1 2 3)
+    ('hello' \ 'l') asString
     "
 !
 
@@ -2345,9 +2329,25 @@
     "
 !
 
+union:aCollection
+    "return a new set containing all elements of the receiver 
+     plus those of the aCollection"
+
+    |newCollection|
+
+    newCollection := self speciesForAdding new.
+    newCollection addAll:self.
+    newCollection addAll:aCollection.
+    ^ newCollection
+
+    "
+     #(0 2 4 6 8) union:#(1 3 5 7)   
+    "
+!
+
 xor:aCollection
     "return a new set containing all elements of the receiver, which are
-     not contained in both mySelf and aCollection.
+     not contained in either the receiver or aCollection, but not in both.
 
     For large collections you better use Sets for bosth self and aCollection"
 
@@ -2562,7 +2562,7 @@
 !Collection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.141 2003-04-03 08:07:54 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.142 2003-04-03 08:45:13 stefan Exp $'
 ! !
 
 Collection initialize!
--- a/Set.st	Thu Apr 03 10:07:54 2003 +0200
+++ b/Set.st	Thu Apr 03 10:45:30 2003 +0200
@@ -612,6 +612,26 @@
     ^ SetInspectorView
 ! !
 
+!Set methodsFor:'obsolete set operations'!
+
++ aCollection
+    "Kept for backward compatibility. Use #union: instead, to isolate
+     arithmethic and set operations"
+
+    <resource: #obsolete>
+
+    ^ self union:aCollection.
+!
+
+- aCollection
+    "Kept for backward compatibility. Use #union: instead, to isolate
+     arithmethic and set operations"
+
+    <resource: #obsolete>
+
+    ^ self \ aCollection
+! !
+
 !Set methodsFor:'private'!
 
 find:key ifAbsent:aBlock
@@ -954,7 +974,6 @@
     ^ tally
 ! !
 
-
 !Set methodsFor:'testing'!
 
 capacity 
@@ -1059,7 +1078,7 @@
 !Set class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.82 2003-04-03 08:06:23 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.83 2003-04-03 08:45:30 stefan Exp $'
 ! !
 
 Set initialize!