Bag.st
changeset 8873 eecab5af2679
parent 8860 b71ebb7e0e5e
child 10835 e23097df1639
--- a/Bag.st	Wed Apr 27 19:32:48 2005 +0200
+++ b/Bag.st	Thu Apr 28 19:28:14 2005 +0200
@@ -39,28 +39,28 @@
 "
     Bag implements collections whose elements are unordered and have no
     external key. Elements may occur more than once in a bag. There is no defined
-    order within a bag. 
-    The default implementation uses a dictionary to store each objects occurence 
-    count, using the object itself as key (i.e. using = and hash for inclusion 
+    order within a bag.
+    The default implementation uses a dictionary to store each objects occurrence
+    count, using the object itself as key (i.e. using = and hash for inclusion
     tests).
 
     There is also an instance creation variant (#identityNew:) creating a
     bag which compares using #== and hashes using #identityHash.
-    (I'd say that an IdentityBag was a better thing to implement ... 
+    (I'd say that an IdentityBag was a better thing to implement ...
      ... but for compatibility ... we do it here as well)
 
     [Instance variables:]
 
-        contents        <Dictionary>    for each element, the number of occurrences
+	contents        <Dictionary>    for each element, the number of occurrences
 
 
     [author:]
-        Claus Gittinger
+	Claus Gittinger
 
     [See also:]
-        Set IdentitySet
-        Dictionary IdentityDictionary
-        OrderedCollection Array
+	Set IdentitySet
+	Dictionary IdentityDictionary
+	OrderedCollection Array
 "
 ! !
 
@@ -134,7 +134,7 @@
      Returns the object.
 
      WARNING: do not add/remove elements while iterating over the receiver.
-              Iterate over a copy to do this."
+	      Iterate over a copy to do this."
 
     |n|
 
@@ -150,7 +150,7 @@
      Returns the object.
 
      WARNING: do not add/remove elements while iterating over the receiver.
-              Iterate over a copy to do this."
+	      Iterate over a copy to do this."
 
     |n|
 
@@ -168,16 +168,16 @@
      otherwise return the removed object.
 
      WARNING: do not add/remove elements while iterating over the receiver.
-              Iterate over a copy to do this."
+	      Iterate over a copy to do this."
 
     |count|
 
     count := contents at:oldObject ifAbsent:0.
     (count == 0) ifTrue:[^ anExceptionBlock value].
     (count == 1) ifTrue:[
-        contents removeKey:oldObject
-    ] ifFalse:[ 
-        contents at:oldObject put:(count - 1)
+	contents removeKey:oldObject
+    ] ifFalse:[
+	contents at:oldObject put:(count - 1)
     ].
     ^ oldObject
 
@@ -211,7 +211,7 @@
      otherwise return the number of removes.
 
      WARNING: do not add/remove elements while iterating over the receiver.
-              Iterate over a copy to do this."
+	      Iterate over a copy to do this."
 
     |count|
 
@@ -246,7 +246,7 @@
     aBag species == self species ifFalse:[^ false].
     self size == aBag size ifFalse:[^ false].
     self valuesAndCountsDo:[:val :cnt |
-        (aBag occurrencesOf:val) == cnt ifFalse:[^ false]
+	(aBag occurrencesOf:val) == cnt ifFalse:[^ false]
     ].
     ^ true
 !
@@ -256,7 +256,7 @@
 
     h := self size.
     self valuesAndCountsDo:[:val :cnt |
-        h := h + cnt hash.
+	h := h + cnt hash.
     ].
     ^ h
 ! !
@@ -301,12 +301,12 @@
     "evaluate the block for all elements in the collection.
 
      WARNING: do not add/remove elements while iterating over the receiver.
-              Iterate over a copy to do this."
+	      Iterate over a copy to do this."
 
     contents keysAndValuesDo:[:key :value|
-        value timesRepeat:[
-            aBlock value:key
-        ]
+	value timesRepeat:[
+	    aBlock value:key
+	]
     ]
 
     "Modified: 1.3.1996 / 21:42:39 / cg"
@@ -314,10 +314,10 @@
 
 valuesAndCountsDo:aTwoArgBlock
     "evaluate the block for all distinct elements in the collection,
-     passing both the element and the occurence count as arguments.
+     passing both the element and the occurrence count as arguments.
 
      WARNING: do not add/remove elements while iterating over the receiver.
-              Iterate over a copy to do this."
+	      Iterate over a copy to do this."
 
     ^ contents keysAndValuesDo:aTwoArgBlock
 
@@ -379,5 +379,5 @@
 !Bag class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.32 2005-04-20 09:26:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.33 2005-04-28 17:28:14 cg Exp $'
 ! !