[Gambas-user] Accessing the nth item in a collection

Jussi Lahtinen jussi.lahtinen at ...626...
Wed Jun 4 16:51:16 CEST 2014


OK, thanks for the answer! But can you elaborate bit further? If the
insertion order is no longer kept, then what dictates the order "For Each"
will enumerate the items? Order of memory addresses?

I mean would the enumeration order be unchanging, but when new item is
added it would be inserted in random (practically from user perspective)
position of the enumeration?


Jussi


On Wed, Jun 4, 2014 at 3:51 PM, Benoît Minisini <
gambas at ...1...> wrote:

> Le 04/06/2014 14:44, Jussi Lahtinen a écrit :
> >> AFAIK, Collection is a hash table and of course, you cannot assume a
> >> particular order of keys in a hash table.
> >>
> >
> > That is my understanding also. But they always seems to be in order they
> > have been added, when you iterate them with "For Each ...".
> >
> > What would cause the disorder?
> >
>
> There are in order by design (the hash table elements are linked both by
> hash slot *and* insertion order).
>
> But I don't guarantee that this non-official feature won't be removed.
>
> Regards,
>
> --
> Benoît Minisini
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list