--- a/Bag.st Wed Jan 09 13:10:52 2008 +0100
+++ b/Bag.st Thu Jan 10 13:00:26 2008 +0100
@@ -9,7 +9,6 @@
other person. No title to or ownership of the software is
hereby transferred.
"
-
"{ Package: 'stx:libbasic' }"
Collection subclass:#Bag
@@ -127,6 +126,7 @@
^ contents
! !
+
!Bag methodsFor:'adding & removing'!
add:newObject
@@ -312,6 +312,18 @@
"Modified: 1.3.1996 / 21:42:39 / cg"
!
+valuesAndCounts
+ "return an orderedCollection containing value->count assocuations"
+
+ |coll|
+
+ coll := OrderedCollection new.
+ self valuesAndCountsDo:[:value :count | coll add:(value->count)].
+ ^ coll
+
+ "Modified: 1.3.1996 / 21:42:44 / cg"
+!
+
valuesAndCountsDo:aTwoArgBlock
"evaluate the block for all distinct elements in the collection,
passing both the element and the occurrence count as arguments.
@@ -379,5 +391,5 @@
!Bag class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.33 2005-04-28 17:28:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.34 2008-01-10 12:00:26 cg Exp $'
! !