SmallDictionary.st
changeset 23365 35e97af75157
parent 23360 d7afaf87196c
child 23696 fa78ebce1022
equal deleted inserted replaced
23364:7c549ad49b78 23365:35e97af75157
   207     "Created: / 14-09-2018 / 15:57:42 / Stefan Vogel"
   207     "Created: / 14-09-2018 / 15:57:42 / Stefan Vogel"
   208 ! !
   208 ! !
   209 
   209 
   210 !SmallDictionary methodsFor:'private'!
   210 !SmallDictionary methodsFor:'private'!
   211 
   211 
   212 growKeysAndValues
   212 grow:capacity 
   213     "duplicate the capacity"
       
   214 
       
   215     self growTo:tally * 2
       
   216 
       
   217     "Modified (comment): / 14-09-2018 / 16:04:17 / Stefan Vogel"
       
   218 !
       
   219 
       
   220 growTo:capacity 
       
   221     |newKeysAndValues|
   213     |newKeysAndValues|
   222 
   214 
   223     newKeysAndValues := Array new:capacity*2.
   215     newKeysAndValues := Array new:capacity*2.
   224     newKeysAndValues replaceFrom:1 to:tally * 2 with:keysAndValues.
   216     newKeysAndValues replaceFrom:1 to:tally * 2 with:keysAndValues.
   225     keysAndValues := newKeysAndValues.
   217     keysAndValues := newKeysAndValues.
   226 
   218 
   227     "Modified (format): / 14-09-2018 / 16:10:49 / Stefan Vogel"
   219     "Created: / 18-09-2018 / 15:37:24 / Stefan Vogel"
       
   220 !
       
   221 
       
   222 growKeysAndValues
       
   223     "duplicate the capacity"
       
   224 
       
   225     self grow:tally * 2
       
   226 
       
   227     "Modified: / 18-09-2018 / 15:37:34 / Stefan Vogel"
   228 !
   228 !
   229 
   229 
   230 privateAt:key put:value
   230 privateAt:key put:value
   231     |sz "{Class: SmallInteger}"|
   231     |sz "{Class: SmallInteger}"|
   232 
   232 
   237         basicAt:sz+2 put:value.
   237         basicAt:sz+2 put:value.
   238     tally := tally + 1.
   238     tally := tally + 1.
   239     ^ value.
   239     ^ value.
   240 
   240 
   241     "Modified: / 18-09-2018 / 13:33:30 / Stefan Vogel"
   241     "Modified: / 18-09-2018 / 13:33:30 / Stefan Vogel"
       
   242 ! !
       
   243 
       
   244 !SmallDictionary methodsFor:'queries'!
       
   245 
       
   246 speciesForCollecting
       
   247     ^ Bag
       
   248 
       
   249     "Created: / 18-09-2018 / 15:34:27 / Stefan Vogel"
   242 ! !
   250 ! !
   243 
   251 
   244 !SmallDictionary methodsFor:'removing'!
   252 !SmallDictionary methodsFor:'removing'!
   245 
   253 
   246 empty
   254 empty
   303 
   311 
   304 isEmpty
   312 isEmpty
   305     ^ tally == 0
   313     ^ tally == 0
   306 
   314 
   307     "Created: / 14-09-2018 / 15:44:49 / Stefan Vogel"
   315     "Created: / 14-09-2018 / 15:44:49 / Stefan Vogel"
       
   316 !
       
   317 
       
   318 isFixedSize
       
   319     "return true if the receiver cannot grow - this will vanish once
       
   320      Arrays and Strings learn how to grow ..."
       
   321 
       
   322     ^ false
       
   323 
       
   324     "Created: / 18-09-2018 / 15:35:25 / Stefan Vogel"
   308 ! !
   325 ! !
   309 
   326 
   310 !SmallDictionary class methodsFor:'documentation'!
   327 !SmallDictionary class methodsFor:'documentation'!
   311 
   328 
   312 version_CVS
   329 version_CVS