diff -r 9ea58e0aad5a -r 985e22966acb Interval.st --- a/Interval.st Fri Apr 13 15:03:30 2012 +0100 +++ b/Interval.st Sat May 05 22:58:24 2012 +0100 @@ -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,15 +689,15 @@ !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 §' ! version_SVN - ^ '$Id: Interval.st 10761 2012-01-19 11:46:00Z vranyj1 $' + ^ '$Id: Interval.st 10807 2012-05-05 21:58:24Z vranyj1 $' ! !