Set.st
changeset 10868 0f72216e1c1d
parent 10588 7043b70ff150
child 11052 0c44bf26275c
equal deleted inserted replaced
10867:eaab8cb9a8c6 10868:0f72216e1c1d
   278 
   278 
   279 add:anObject
   279 add:anObject
   280     "add the argument, anObject to the receiver.
   280     "add the argument, anObject to the receiver.
   281 
   281 
   282      WARNING: do not add elements while iterating over the receiver.
   282      WARNING: do not add elements while iterating over the receiver.
   283 	      Iterate over a copy to do this."
   283               Iterate over a copy to do this."
   284 
   284 
   285     |index "{ Class: SmallInteger }"|
   285     |index "{ Class: SmallInteger }"|
   286 
   286 
   287     anObject isNil ifTrue:[
   287     anObject isNil ifTrue:[  
   288 	^ self invalidElementError.
   288         ^ self invalidElementError.
   289     ].
   289     ].
   290 
   290 
   291     index := self findKeyOrNil:anObject.
   291     index := self findKeyOrNil:anObject.
   292     (keyArray basicAt:index) isNil ifTrue:[
   292     (keyArray basicAt:index) isNil ifTrue:[
   293 	"/ not already there
   293         "/ not already there
   294 	keyArray basicAt:index put:anObject.
   294         keyArray basicAt:index put:anObject.
   295 	tally := tally + 1.
   295         tally := tally + 1.
   296 
   296 
   297 	self fullCheck.
   297         self fullCheck.
   298     ].
   298     ].
   299     ^ anObject
   299     ^ anObject
   300 
   300 
   301     "Modified: 30.1.1997 / 14:58:08 / cg"
   301     "Modified: 30.1.1997 / 14:58:08 / cg"
   302 !
   302 !
   461     ^ true.
   461     ^ true.
   462 
   462 
   463     "Modified: 30.1.1997 / 14:58:08 / cg"
   463     "Modified: 30.1.1997 / 14:58:08 / cg"
   464 ! !
   464 ! !
   465 
   465 
   466 
       
   467 !Set methodsFor:'comparing'!
   466 !Set methodsFor:'comparing'!
   468 
   467 
   469 = aCollection
   468 = aCollection
   470     "return true, if the argument is a Set containing the same elements
   469     "return true, if the argument is a Set containing the same elements
   471      as I do"
   470      as I do"
  1014     "return the number of set elements"
  1013     "return the number of set elements"
  1015 
  1014 
  1016     ^ tally
  1015     ^ tally
  1017 ! !
  1016 ! !
  1018 
  1017 
  1019 
       
  1020 !Set methodsFor:'testing'!
  1018 !Set methodsFor:'testing'!
  1021 
  1019 
  1022 capacity 
  1020 capacity 
  1023     "return the number of elements, that the receiver is
  1021     "return the number of elements, that the receiver is
  1024      prepared to take.
  1022      prepared to take.
  1116 ! !
  1114 ! !
  1117 
  1115 
  1118 !Set class methodsFor:'documentation'!
  1116 !Set class methodsFor:'documentation'!
  1119 
  1117 
  1120 version
  1118 version
  1121     ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.100 2007-06-04 07:26:44 stefan Exp $'
  1119     ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.101 2008-02-05 13:49:29 sr Exp $'
  1122 ! !
  1120 ! !
  1123 
  1121 
  1124 Set initialize!
  1122 Set initialize!