--- a/SequenceableCollection.st Wed Sep 12 11:42:52 2001 +0200
+++ b/SequenceableCollection.st Wed Sep 12 13:10:35 2001 +0200
@@ -2342,6 +2342,39 @@
"
!
+from:startIndex to:stopIndex select:aBlock
+ "evaluate the argument, aBlock for the elements at startIndex..stopIndex
+ and return a collection of those elements for which the block return true."
+
+ |element newColl species needCopy
+ n "{ Class:SmallInteger }"|
+
+ n := stopIndex - startIndex + 1.
+ species := self species.
+ species growIsCheap ifFalse:[
+ newColl := OrderedCollection new:n.
+ needCopy := true
+ ] ifTrue:[
+ newColl := self copyEmpty:n.
+ needCopy := false
+ ].
+ startIndex to:stopIndex do:[:index |
+ element := self at:index.
+ (aBlock value:element) ifTrue:[
+ newColl add:element
+ ].
+ ].
+ needCopy ifTrue:[
+ newColl := (species withAll:newColl) postCopyFrom:self
+ ].
+ ^ newColl
+
+ "
+ #(faba one two three four five six)
+ from:2 to:5 select:[:element | element startsWith:'f']
+ "
+!
+
keysAndValuesDo:aTwoArgBlock
"evaluate the argument, aBlock for every element in the collection,
passing both index and element as arguments."
@@ -5270,6 +5303,6 @@
!SequenceableCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.153 2001-09-04 12:45:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.154 2001-09-12 11:10:35 cg Exp $'
! !
SequenceableCollection initialize!