New method #sameContentsAs:
authorStefan Vogel <sv@exept.de>
Thu, 23 Sep 1999 18:04:23 +0200
changeset 4795 4bdb6488d5b2
parent 4794 19e05d7c2d3b
child 4796 eee167a75fcd
New method #sameContentsAs:
Set.st
--- a/Set.st	Thu Sep 23 15:23:10 1999 +0200
+++ b/Set.st	Thu Sep 23 18:04:23 1999 +0200
@@ -784,6 +784,39 @@
     ^ 1
 !
 
+sameContentsAs:aCollection
+    "answer true, if all the elements in self and aCollection
+     are common. This is not defined as #=, since we cannot redefine #hash
+     for aCollection."
+
+    aCollection size ~~ self size ifTrue:[
+        ^ false
+    ].
+
+    aCollection do:[:e|
+        (self includes:e) ifFalse:[
+            ^ false.
+        ]
+    ].
+
+    ^ true.
+
+
+    "
+      #(1 2 3) asSet sameContentsAs: #(1 2 3)
+      #(1 2 3 4) asSet sameContentsAs: #(1 2 3)
+      #(1 2 3) asSet sameContentsAs: #(1 2 3 3)
+      #(1 2 3 'aa') asSet sameContentsAs: #(1 2 3 'aa')
+      #(1 2 3 'aa') asIdentitySet sameContentsAs: #(1 2 3 'aa')
+      #(1 2 3 #aa) asIdentitySet sameContentsAs: #(1 2 3 #aa)
+    "
+
+
+
+
+
+!
+
 size
     "return the number of set elements"
 
@@ -811,6 +844,6 @@
 !Set class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.58 1999-03-01 15:59:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.59 1999-09-23 16:04:23 stefan Exp $'
 ! !
 Set initialize!