Dict.st
changeset 1221 46d72af387e9
parent 1146 edadea7273b6
child 1233 21452b1c61eb
equal deleted inserted replaced
1220:99990bbb561f 1221:46d72af387e9
   193     ^ exceptionBlock value.
   193     ^ exceptionBlock value.
   194 !
   194 !
   195 
   195 
   196 at:aKey put:anObject
   196 at:aKey put:anObject
   197     "add the argument anObject under key, aKey to the receiver.
   197     "add the argument anObject under key, aKey to the receiver.
   198 
   198      Return anObject (sigh).
   199      WARNING: do not add elements while iterating over the receiver.
   199      WARNING: do not add elements while iterating over the receiver.
   200 	      Iterate over a copy to do this."
   200               Iterate over a copy to do this."
   201 
   201 
   202     |index "{ Class: SmallInteger }" |
   202     |index "{ Class: SmallInteger }" |
   203 
   203 
   204     aKey isNil ifTrue:[
   204     aKey isNil ifTrue:[
   205 	"nil is not allowed as key"
   205         "nil is not allowed as key"
   206 	self errorInvalidKey:aKey
   206         self errorInvalidKey:aKey
   207     ] ifFalse:[
   207     ] ifFalse:[
   208 	index := self findKeyOrNil:aKey.
   208         index := self findKeyOrNil:aKey.
   209 	(valueArray basicAt:index) notNil ifTrue:[
   209         (valueArray basicAt:index) notNil ifTrue:[
   210 	    valueArray basicAt:index put:anObject.
   210             valueArray basicAt:index put:anObject.
   211 	    ^ anObject
   211             ^ anObject
   212 	].
   212         ].
   213 	keyArray basicAt:index put:aKey.
   213         keyArray basicAt:index put:aKey.
   214 	valueArray basicAt:index put:anObject.
   214         valueArray basicAt:index put:anObject.
   215 	tally := tally + 1.
   215         tally := tally + 1.
   216 
   216 
   217 	self fullCheck.
   217         self fullCheck.
   218     ].
   218     ].
   219     ^ anObject
   219     ^ anObject
   220 
   220 
   221     "Modified: 1.3.1996 / 21:24:13 / cg"
   221     "Modified: 19.4.1996 / 11:19:45 / cg"
   222 !
   222 !
   223 
   223 
   224 keyAtEqualValue:aValue
   224 keyAtEqualValue:aValue
   225     "return the key whose value is equal (i.e. using #= for compare)
   225     "return the key whose value is equal (i.e. using #= for compare)
   226      to the argument, nil if none found.
   226      to the argument, nil if none found.
  1086 ! !
  1086 ! !
  1087 
  1087 
  1088 !Dictionary class methodsFor:'documentation'!
  1088 !Dictionary class methodsFor:'documentation'!
  1089 
  1089 
  1090 version
  1090 version
  1091     ^ '$Header: /cvs/stx/stx/libbasic/Attic/Dict.st,v 1.35 1996-04-09 20:50:52 cg Exp $'
  1091     ^ '$Header: /cvs/stx/stx/libbasic/Attic/Dict.st,v 1.36 1996-04-19 10:46:37 cg Exp $'
  1092 ! !
  1092 ! !