class: Bag
added: #initContents
comment/format in: #asSet
changed:
#asAssociations
#includes:
#printElementsDo:
changed for easier subclassability
--- a/Bag.st Wed Jan 23 11:46:37 2013 +0100
+++ b/Bag.st Wed Jan 23 18:14:50 2013 +0100
@@ -106,7 +106,7 @@
to the bags elements.
Same as #contents for dolphin compatibility."
- ^ contents
+ ^ self contents
! !
!Bag methodsFor:'accessing'!
@@ -356,8 +356,8 @@
!Bag methodsFor:'printing & storing'!
printElementsDo:aBlock
- contents keysAndValuesDo:[:key :value|
- aBlock value:('%1(*%2)' bindWith:key with:value).
+ self valuesAndCountsDo:[:value :count|
+ aBlock value:('%1(*%2)' bindWith:value with:count).
]
! !
@@ -404,7 +404,7 @@
includes:anObject
"return true, if anObject is in the receiver"
- ^ contents includesKey:anObject
+ ^ (self occurrencesOf:anObject) > 0
!
occurrencesOf:anObject
@@ -416,9 +416,10 @@
!Bag class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.41 2010-03-30 13:38:23 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.42 2013-01-23 17:14:50 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.41 2010-03-30 13:38:23 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.42 2013-01-23 17:14:50 cg Exp $'
! !
+