[squeak-dev] HashedCollection fixes

Levente Uzonyi leves at elte.hu
Mon Apr 12 23:39:44 UTC 2010


I started to write some docs for HashedCollection and found two issues. 
One of them is a minor problem: sending add:withOccurrences: will add the 
object to the collection even if the argument is 0 or negative.
The other is issue is a bit more serious. Symbol class >> 
#compactSymbolTable is changing the internal state of SymbolTable via 
private methods. This means that after compacting SymbolTable, the 
capacity will not be prime most of the time which may lead to inferior 

To solve the problem I pushed a few packages to the Inbox (not the Trunk, 
since 4.1 works without these changes) which contain other changes/fixes 
and some documentation. To try the changes evaluate this:

Installer squeak
 	project: 'inbox';
 	install: 'Tests-ul.75.mcz';
 	install: 'CollectionsTests-ul.160.mcz';
 	install: 'Collections-ul.355.mcz';
 	"new mcm required here"
 	install: 'Collections-ul.356.mcz';
 	install: 'Kernel-ul.441.mcz'

After loading the packages and evaluating [Symbol compactSymbolTable] both 
issues should be fixed.

For future releases one may consider using [HashedCollection compactAll]
- which as the name suggests compacts all HashedCollections - instead of 
the current compaction methods. Note that compacting HashedCollections 
may lead to >75% load factor in some edge cases. The larger the collection 
the smaller the difference will be. (For example a collection with 4 
elements will have 80% load factor, with 13 elements 76.47%, while with 
202 elements will have 75.09%. These are all edge cases, normally the 
load factor is less than 75%.)


More information about the Squeak-dev mailing list