[Newbies] Does Set respect ordering?
Thiede, Christoph
Christoph.Thiede at student.hpi.uni-potsdam.de
Tue Feb 11 15:11:13 UTC 2020
Hi tty,
Set does not guarantee the order of elements. It's an implementation detail. If you only need to remove duplicates, have a look at #withoutDuplicates.
<http://www.hpi.de/>
Does this help? :-)
Best,
Christoph
________________________________
Von: Beginners <beginners-bounces at lists.squeakfoundation.org> im Auftrag von tty <gettimothy at zoho.com>
Gesendet: Dienstag, 11. Februar 2020 16:07:15
An: beginners at lists.squeakfoundation.org
Betreff: [Newbies] Does Set respect ordering?
Hi Folks.
If I have an OrderedCollection and convert it to Set via asSet, am I
guaranteed that the resulting Set contains elements in the same order as the
OrderedCollection?
Here is my problem.
I have an OrderedCollection with the same element in it twice. By same
element, I mean they are the same object.
*an OrderedCollection(
A
NESTED TABLE CELL
B
A
NESTED TABLE CELL
)
*
Above, the first and third elements are the same XMLElement. I now this
because if I inspect them and then change one, the other changes.
if I run asSet on the OrderedCollection, I get what I need:
*a Set( A
NESTED TABLE CELL
B)*
In that conversion, can I rely on that Ordering being preserved?
If not, a pointer to the correct select/reject/inject/detect...sort of thing
would be much appreciated.
cheers.
--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
Beginners at lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20200211/db0ece26/attachment.html>
More information about the Beginners
mailing list