[Newbies] Ordered Set?
Ron at USMedRec.com
Sun Nov 4 13:58:43 UTC 2007
I see that you have been asked already but, could you please give us a name
we can use besides itsme213?
You can use SortedCollection.
SortedCollection new sortBlock: [:a :b | a index < b index]. This provides
ordering but does not eliminate duplicates. That can be accomplished pretty
simply by checking for uniqueness before adding to the collection.
You could also use a Dictionary, if your data is not too large.
aDict := Dictionary new.
aDict at: anObject index ifAbsentPut: anObject.
This provides both sorting and set like operations (again by checking for
uniqueness before adding).
Otherwise just use OrderedCollection and manage order and uniqueness
manually. The class has all the methods you need to do so.
> -----Original Message-----
> From: beginners-bounces at lists.squeakfoundation.org [mailto:beginners-
> bounces at lists.squeakfoundation.org] On Behalf Of itsme213
> Sent: Saturday, November 03, 2007 11:27 PM
> To: beginners at lists.squeakfoundation.org
> Subject: [Newbies] Ordered Set?
> I have ordered collections of things without duplicates and with an index
> 1...N for each, ideally with operations like
> move: anExistingElement to: anExistingPosition
> What should I use? I could not find an OderedSet?
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
More information about the Beginners