Re: [Vala] [LibGee] LinkedList does not increase stamp



Re Tomaž,

Quikee wrote:
In the add and insert methods of LinkedList I saw this two line:

// Adding items to the list during iterations is allowed.
//++this._stamp;

Additionally remove_at and/or remove also does not increase the stamp.

But this is the wrong way to do this! Stamp should be increased always
but the iterator should be changed if you want to allow changing of
the list during iteration.

The author of the doubly Linked List, Mark Lee, claimed that items can
be added, inserted and removed during iterations. Hence this has been
put in comment to "document" the choice. This should IMHO be specified
in the valadoc comment.

I would go even further and make stamp a read-only property on the
Collection interface. The trick is that with this "outside" Iterators
could be build - for example a SortedIterator for every Collection.
Such a iterator could then do a to_array and sort the list for the
iteration, but such an iterator needs to know if the collection he
used as the origin was changed from the outside or not. If it was it
should make the iterator invalid and not allow the iteration to
proceed (in whatever way). Such an iterator could be extended to allow
such cases but only through the iterator and not from outside.

stamp is an implementation detail. IMHO, we should not make it public.

The support for sorted collections (and thus iterator) can be achieved
with views:

We will support for collection change event notification. Views will be
wrapper collections (such as ReadOnly*) that would register to the
collection change event notification.

I wonder if this covers your use case ?

We will have such SortedCollection wrappers in the future. I would like
that to become part of the API for libgee 0.7.

BTW. It would be nice if LibGee would have its own mailing list as well. :)

Hum... Maybe it is a bit early. If Vala list readers don't mind we will
make some noise here for some more time! :)

BTW I'd like to thank you a lot for all your contribution.
Cheers, Didier.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]