Bag.st
changeset 11 6bf3080856be
parent 5 67342904af11
child 54 06dbdeeed4f9
equal deleted inserted replaced
10:4f1f9a91e406 11:6bf3080856be
    29 
    29 
    30 Instance variables:
    30 Instance variables:
    31 
    31 
    32 contents        <Dictionary>        for each element, the number of occurrences
    32 contents        <Dictionary>        for each element, the number of occurrences
    33 
    33 
    34 $Header: /cvs/stx/stx/libbasic/Bag.st,v 1.4 1993-10-13 02:11:00 claus Exp $
    34 $Header: /cvs/stx/stx/libbasic/Bag.st,v 1.5 1993-12-11 00:41:17 claus Exp $
    35 written jun 91 by claus
    35 written jun 91 by claus
    36 '!
    36 '!
    37 
    37 
    38 !Bag class methodsFor:'instance creation'!
    38 !Bag class methodsFor:'instance creation'!
    39 
    39 
    99     "return true, if anObject is in the receiver"
    99     "return true, if anObject is in the receiver"
   100 
   100 
   101     ^ contents includesKey:anObject
   101     ^ contents includesKey:anObject
   102 ! !
   102 ! !
   103 
   103 
       
   104 !Bag methodsFor:'converting'!
       
   105 
       
   106 asBag
       
   107     "return the receiver as a bag"
       
   108 
       
   109     "could be an instance of a subclass..."
       
   110     self class == Bag ifTrue:[
       
   111         ^ self
       
   112     ].
       
   113     ^ super asBag
       
   114 ! !
       
   115 
   104 !Bag methodsFor:'adding & removing'!
   116 !Bag methodsFor:'adding & removing'!
   105 
   117 
   106 add:anObject
   118 add:anObject
   107     "add the argument, anObject to the receiver"
   119     "add the argument, anObject to the receiver"
   108 
   120