--- a/Collection.st Mon Dec 15 14:34:57 2008 +0100
+++ b/Collection.st Mon Dec 15 15:08:00 2008 +0100
@@ -1109,6 +1109,23 @@
^ aDoubleArray
!
+asFlatOrderedCollection
+ |coll|
+
+ coll := OrderedCollection new.
+ self flatDo:[:el | coll add:el].
+ ^ coll.
+
+ "
+ #(
+ (1 2 3)
+ 4 5
+ (6)
+ 7
+ (8 (9 10) 11 12 (13 (14 (15) 16)))) asFlatOrderedCollection
+ "
+!
+
asFloatArray
"return a new FloatArray with the collections elements
(which must convert to floats)."
@@ -1845,6 +1862,28 @@
"Modified: 18.4.1996 / 14:16:59 / cg"
!
+flatDo:aBlock
+ "for each element of the collection, if its a scalar, evaluate aBlock for it;
+ otherwise, recursively invoke flatDo on the collection."
+
+ self do:[:each |
+ (each isNonByteCollection) ifTrue:[
+ each flatDo:aBlock
+ ] ifFalse:[
+ aBlock value:each
+ ].
+ ].
+
+ "
+ #(
+ (1 2 3)
+ 4 5
+ (6)
+ 7
+ (8 (9 10) 11 12 (13 (14 (15) 16)))) flatDo:[:el | Transcript showCR:el]
+ "
+!
+
inject:thisValue into:binaryBlock
"starting with thisValue for value, pass this value and each element
to binaryBlock, replacing value with the result returned from the block
@@ -2327,6 +2366,16 @@
! !
+!Collection methodsFor:'operations'!
+
+decrementAt:aKey
+ self at:aKey put:(self at:aKey) - 1.
+!
+
+incrementAt:aKey
+ self at:aKey put:(self at:aKey) + 1.
+! !
+
!Collection methodsFor:'printing & storing'!
displayString
@@ -3275,7 +3324,7 @@
!Collection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.210 2008-12-02 17:10:42 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.211 2008-12-15 14:08:00 cg Exp $'
! !
Collection initialize!