Hi itsme,
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.
Happy Coding!
Ron Teitelbaum
> -----Original Message-----
> From:
[hidden email] [mailto:beginners-
>
[hidden email]] On Behalf Of itsme213
> Sent: Saturday, November 03, 2007 11:27 PM
> To:
[hidden email]
> 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
>
[hidden email]
>
http://lists.squeakfoundation.org/mailman/listinfo/beginners_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners