QotD    "To be or not to be" – Shakespeare
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
OrderedSet implementation
Last updated at 7:05 pm UTC on 28 November 2018
An implementation of an OrderedSet

The repository is http://www.squeaksource.com/PharoTaskForces, the package
is OrderedSet, and the latest version is OrderedSet-StephaneDucasse.2.mcz

Levente Uzonyi Wed, Nov 28, 2018 at 6:48 PM
To: The general-purpose Squeak developers list

That OrderedSet is not really a set, just a thin wrapper over OrderedCollection, so performance will be surprisingly bad.

Squeak has OrderedDictionary which has all the methods a Set needs:
#at: anObject put: nil <=> #add: anObject
#includesKey: anObject <=> #includes:anObject
#keysDo: aBlock <=> #do: aBlock
#removeKey: anObject <=> #remove: anObject

Note that removal will take O(size) time. If you need anything better, you have to implement your own set (e.g. a linked hash set. Squeak's LRUCache has a list implementation that can come handy).