+reverseDo:
authorClaus Gittinger <cg@exept.de>
Wed, 22 Oct 2008 12:49:27 +0200
changeset 11270 a616ba9b7f81
parent 11269 f45a4a2cd7ab
child 11271 5b75b4a7fb35
+reverseDo:
Interval.st
--- a/Interval.st	Wed Oct 22 11:50:19 2008 +0200
+++ b/Interval.st	Wed Oct 22 12:49:27 2008 +0200
@@ -253,8 +253,8 @@
 
 collect:aBlock
     "evaluate the argument, aBlock for every element in the collection
-     and return a collection of the results - Redefined since SeqColl
-     accesses the receiver via at:, which is slow for intervals"
+     and return a collection of the results.
+     Redefined since SeqColl accesses the receiver via at:, which is slow for intervals"
 
     |newCollection|
 
@@ -274,13 +274,13 @@
     "
      (1 to:20) collect:[:i | i*i]  
     "
+
+    "Modified: / 22-10-2008 / 12:47:52 / cg"
 !
 
 do:aBlock
-    "evaluate the argument, aBlock for every element in the
-     receiver-interval. 
-     Redefined since SeqColl accesses the receiver with at:, which is
-     slow for intervals."
+    "evaluate the argument, aBlock for every element in the receiver-interval. 
+     Redefined since SeqColl accesses the receiver with at:, which is slow for intervals."
 
     |aValue iter|
 
@@ -322,13 +322,29 @@
      2.0 to:1.0 by:-0.25 do:[:v | Transcript showCR:v]
      $a to:$z do:[:v | Transcript showCR:v]
     "
+
+    "Modified: / 22-10-2008 / 12:47:30 / cg"
+!
+
+reverseDo:aBlock
+    "evaluate the argument, aBlock for every element in the receiver-interval in
+     reverse order. 
+     Redefined since SeqColl accesses the receiver with at:, which is slow for intervals."
+
+    ^ self reversed do:aBlock
+
+    "
+     (1 to:10) do:[:el | Transcript showCR:el ].
+     (1 to:10) reverseDo:[:el | Transcript showCR:el ].
+    "
+
+    "Modified: / 22-10-2008 / 12:49:28 / cg"
 !
 
 select:aBlock
     "evaluate the argument, aBlock for every element in the collection
-     and return a collection of all elements for which the block return
-     true. Redefined since SeqColl accesses the receiver with at:, which is
-     slow for intervals."
+     and return a collection of all elements for which the block return true. 
+     Redefined since SeqColl accesses the receiver with at:, which is slow for intervals."
 
     |newColl|
 
@@ -341,6 +357,8 @@
     "
      (1 to:20) select:[:i | i even]
     "
+
+    "Modified: / 22-10-2008 / 12:47:41 / cg"
 ! !
 
 !Interval methodsFor:'printing & storing'!
@@ -600,5 +618,5 @@
 !Interval class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.45 2008-10-22 07:17:55 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.46 2008-10-22 10:49:27 cg Exp $'
 ! !