Collection.st
changeset 6695 dc0a9be75187
parent 6672 c5a5a9f9f4f5
child 6757 f0a9574cfb4e
--- a/Collection.st	Wed Jul 31 17:07:40 2002 +0200
+++ b/Collection.st	Wed Jul 31 17:35:19 2002 +0200
@@ -1657,6 +1657,21 @@
     "
 !
 
+select:selectBlock thenDo:doBlock
+    "combination of select followed by do
+     Avoids the creation of intermediate garbage"
+
+    self do:[:eachElement |
+        (selectBlock value:eachElement) ifTrue:[
+            doBlock value:eachElement
+        ]
+    ].
+
+    "
+     #(1 2 3 4 5 6 7) select:[:i | i even] thenDo:[:i | Transcript showCR:i]
+    "
+!
+
 triplesDo:aBlock
     "evaluate the argument, aBlock for every element in the collection,
      which is supposed to consist of 3-element collections.
@@ -2417,6 +2432,6 @@
 !Collection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.127 2002-07-31 08:39:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.128 2002-07-31 15:35:19 cg Exp $'
 ! !
 Collection initialize!