--- a/Collection.st Wed Apr 06 13:25:19 2011 +0100
+++ b/Collection.st Sat Apr 09 18:19:04 2011 +0100
@@ -259,7 +259,6 @@
^ self withSize:n
! !
-
!Collection class methodsFor:'Signal constants'!
emptyCollectionSignal
@@ -480,7 +479,6 @@
].
! !
-
!Collection methodsFor:'accessing'!
anElement
@@ -1236,23 +1234,27 @@
!Collection methodsFor:'bulk operations'!
abs
- "Absolute value of all elements in the collection"
+ "absolute value of all elements in the collection"
^ self collect: [:a | a abs]
"
TestCase assert:( { 1. -2. -3. 4 } abs = { 1. 2. 3. 4 }).
"
+
+ "Modified: / 18-03-2011 / 10:33:50 / cg"
!
negated
- "Negated value of all elements in the collection"
+ "negated value of all elements in the collection"
^ self collect:[:a | a negated]
"
TestCase assert:( { 1. -2. -3. 4 } negated = { -1. 2. 3. -4 }).
"
+
+ "Modified: / 18-03-2011 / 10:33:53 / cg"
!
product
@@ -1386,6 +1388,9 @@
!
asFlatOrderedCollection
+ "return a new ordered collection containing all elements of the receiver
+ and recursively of all collectionelements from the receiver"
+
|coll|
coll := OrderedCollection new.
@@ -1398,8 +1403,11 @@
4 5
(6)
7
- (8 (9 10) 11 12 (13 (14 (15) 16)))) asFlatOrderedCollection
+ (8 (9 10) 11 12 (13 (14 (15) 16)))
+ ) asFlatOrderedCollection
"
+
+ "Modified: / 20-03-2011 / 22:02:36 / cg"
!
asFloatArray
@@ -2792,11 +2800,19 @@
!Collection methodsFor:'operations'!
decrementAt:aKey
+ "decrement the value at aKey by one"
+
self at:aKey put:(self at:aKey) - 1.
+
+ "Modified: / 18-03-2011 / 10:32:04 / cg"
!
incrementAt:aKey
+ "increment the value at aKey by one"
+
self at:aKey put:(self at:aKey) + 1.
+
+ "Modified: / 18-03-2011 / 10:31:57 / cg"
! !
!Collection methodsFor:'printing & storing'!
@@ -3023,6 +3039,18 @@
!Collection methodsFor:'queries'!
+average
+ "average value of all elements in the collection"
+
+ ^ self sum / self size
+
+ "
+ TestCase assert:( { 1. 2. 3. 4 } average = 2.5).
+ "
+
+ "Created: / 18-03-2011 / 10:31:04 / cg"
+!
+
defaultElement
^ nil
!
@@ -3253,7 +3281,7 @@
maxApplying:aBlock
"return the maximum value from applying aBlock to each element in the receiver collection,
- using < to compare elements.
+ using aBlock to compare elements.
Raises an error, if the receiver is empty."
self emptyCheck.
@@ -3275,6 +3303,7 @@
"
"Created: / 23-08-2010 / 11:02:50 / cg"
+ "Modified: / 18-03-2011 / 10:32:29 / cg"
!
min
@@ -3304,7 +3333,7 @@
minApplying:aBlock
"return the minimum value from applying aBlock to each element in the receiver collection,
- using < to compare elements.
+ using aBlock to compare elements.
Raises an error, if the receiver is empty."
self emptyCheck.
@@ -3326,6 +3355,7 @@
"
"Created: / 23-08-2010 / 11:01:42 / cg"
+ "Modified: / 18-03-2011 / 10:32:33 / cg"
!
minMax
@@ -3872,15 +3902,15 @@
!Collection class methodsFor:'documentation'!
version
- ^ '$Id: Collection.st 10604 2011-02-04 23:09:23Z vranyj1 $'
+ ^ '$Id: Collection.st 10632 2011-04-09 17:19:04Z vranyj1 $'
!
version_CVS
- ^ 'Header: /cvs/stx/stx/libbasic/Collection.st,v 1.253 2011/01/22 08:13:45 cg Exp '
+ ^ 'Header: /var/local/cvs/stx/libbasic/Collection.st,v 1.256 2011-03-20 21:52:46 cg Exp '
!
version_SVN
- ^ '$Id: Collection.st 10604 2011-02-04 23:09:23Z vranyj1 $'
+ ^ '$Id: Collection.st 10632 2011-04-09 17:19:04Z vranyj1 $'
! !
Collection initialize!
@@ -3893,3 +3923,4 @@
+