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?
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: beginners-bounces@lists.squeakfoundation.org [mailto:beginners- bounces@lists.squeakfoundation.org] On Behalf Of itsme213 Sent: Saturday, November 03, 2007 11:27 PM To: beginners@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@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
"Ron Teitelbaum" Ron@USMedRec.com wrote
I see that you have been asked already but, could you please give us a name we can use besides itsme213?
But of course ... I had not realized my signature was broken.
Thanks ... Sophie.
Thanks Sophie,
It's nice to meet you!
Ron
-----Original Message----- From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners- bounces@lists.squeakfoundation.org] On Behalf Of itsme213 Sent: Sunday, November 04, 2007 10:55 AM To: beginners@lists.squeakfoundation.org Subject: [Newbies] Re: Ordered Set?
"Ron Teitelbaum" Ron@USMedRec.com wrote
I see that you have been asked already but, could you please give us a name we can use besides itsme213?
But of course ... I had not realized my signature was broken.
Thanks ... Sophie.
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
beginners@lists.squeakfoundation.org