> On Oct 31, 2015, at 4:10 PM, Andrea Zagli <aza...@libero.it> wrote:
> 
> Il giorno ven 30 ott 2015 19:09:47 CET, Emmanuele Bassi ha scritto:
>> Hi;
>> 
>>> On 30 October 2015 at 16:43, Andrea Zagli <aza...@libero.it> wrote:
>>> is there a data type, similar to array, that preserve the order on which
>>> elements are inserted?
>> 
>> All the array and list types preserve the order of insertion. For
>> obvious reasons, GHashTable doesn't.
>> 
>>> for example ghashtable and gptrarray doesn't preserve the order, so when
>>> they are traversed (for example with a "for" cicle, regarding gptrarray) the
>>> order may be not the same when elements are inserted
>> 
>> GPtrArray preserves the order of insertion — it's an array, after all.
>> Why do you think it does not?
> 
> it is written on the help
> 
> https://developer.gnome.org/glib/stable/glib-Pointer-Arrays.html
> 
> "If you remove elements from the array, elements at the end of the array are 
> moved into the space previously occupied by the removed element. This means 
> that you should not rely on the index of particular elements remaining the 
> same."
> 

Elements plural here.

The order of elements in a pointer array are preserved and do not change, the 
above comment only points out that arrays do not become "sparse" when removing 
elements. A given index cannot be expected to be valid after removing elements.

Cheers,
    -Tristan

> 
> may be also other data type makes the same thing? i didn't find reference 
> about that
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to