--- a/SequenceableCollection.st Thu Aug 27 13:35:28 2009 +0200
+++ b/SequenceableCollection.st Thu Aug 27 14:28:53 2009 +0200
@@ -1972,6 +1972,34 @@
!SequenceableCollection methodsFor:'converting'!
+asCollectionOfSubCollectionsOfSize:pieceSize
+ "return a collection containing pieces of size pieceSite from the receiver.
+ The last piece may be smaller, if the receivers size is not a multiple of pieceSize."
+
+ |pieces
+ start "{ Class:SmallInteger }"
+ stop "{ Class:SmallInteger }"
+ mySize "{ Class:SmallInteger }"|
+
+ pieces := OrderedCollection new.
+ start := 1. stop := start + pieceSize - 1.
+ mySize := self size.
+ [stop <= mySize] whileTrue:[
+ pieces add:(self copyFrom:start to:stop).
+ start := start + pieceSize.
+ stop := stop + pieceSize.
+ ].
+ (start <= mySize) ifTrue:[
+ pieces add:(self copyFrom:start to:mySize).
+ ].
+ ^ pieces
+
+ "
+ '123123123123123123' asCollectionOfSubCollectionsOfSize:3
+ '12312312312312312312' asCollectionOfSubCollectionsOfSize:3
+ "
+!
+
asCollectionOfSubCollectionsSeparatedBy:anElement
"return a collection containing the subcollections (separated by anElement)
of the receiver. If anElement occurs multiple times in a row,
@@ -7598,7 +7626,7 @@
!SequenceableCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.276 2009-08-27 11:35:28 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.277 2009-08-27 12:28:53 cg Exp $'
! !
SequenceableCollection initialize!