diff -r db6f6d13cd5a -r 32cf030cebca Interval.st --- a/Interval.st Wed Apr 25 21:09:47 2012 +0200 +++ b/Interval.st Thu May 03 18:31:40 2012 +0200 @@ -286,28 +286,25 @@ 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" + Redefined since the inherited method (SeqColl) accesses the receiver via at:, + which is slow for intervals" - |newCollection| + |elementValue mySize newCollection| - (start == 1 and:[step == 1]) ifTrue:[ - newCollection := Array new:(self size). - self do:[:each | - newCollection at:each put:(aBlock value:each) - ]. - ] ifFalse:[ - newCollection := self species new:(self size). - self do:[:each | - newCollection add:(aBlock value:each) - ]. + elementValue := start. + newCollection := Array new:(mySize := self size). + 1 to: mySize do:[:i | + newCollection at:i put:(aBlock value:elementValue). + elementValue := elementValue + step. ]. - ^ newCollection + ^ newCollection " - (1 to:20) collect:[:i | i*i] + (1 to:20 by:2) collect:[:i | i*i] " - "Modified: / 22-10-2008 / 12:47:52 / cg" + "Modified: / 03-05-2012 / 16:48:16 / cg" + "Modified (comment): / 03-05-2012 / 18:31:01 / cg" ! do:aBlock @@ -692,9 +689,9 @@ !Interval class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.52 2010-09-21 06:57:23 stefan Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.53 2012-05-03 16:31:40 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.52 2010-09-21 06:57:23 stefan Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.53 2012-05-03 16:31:40 cg Exp $' ! !