[squeak-dev] Ideas about sets and dictionaries round #2

Levente Uzonyi leves at elte.hu
Tue Nov 17 13:57:51 UTC 2009


On Tue, 17 Nov 2009, Nicolas Cellier wrote:

> 2009/11/17 Levente Uzonyi <leves at elte.hu>:
>> - add #keySet to dictionaries which returns a set with the keys, since #keys
>> now returns an Array
>>
>
> If it add something to keys asSet, why not.
> For large collections a clever trick could be to not rehash the keys
> (Use a Set of same capacity...).
>

The idea is to (ab)use the fact that every dictionary has a set which is 
hashed the same way as the dictionary's keys. So a dictionary can create a 
set stub without an array, collect it's keys into an array and inject it 
into the set. This way creating a set with the keys is basically just a 
#collect: of the dictionary's array.

Levente

> cheers
> Nicolas
>



More information about the Squeak-dev mailing list