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



On Sun, 2009-08-02 at 20:50 +0200, Didier "Ptitjes" wrote:
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.


That's seem no longer true as Node<G> is compact class since da07618a. I
changed it, I believe, not knowing that the class was suppose to be
deletion-safe and following comment "Maybe a compact class should be
used?" (the previous implementation had memory leak).

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.


There was well-motivated bug report that asked about signals being added
(to allow use GObject goodies IIRC). That would cover also this case at
least to some extend.

I cannot find it right now - I think it might be deleted during last
bugzilla crash.

I haven't implemented it yet which seems ironic as it is one of few
features not blocked by lack of vala features (currently - mostly
unreviewed/unapplied patches - I'm trying to regularly nag to get the
reviewed)

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! :)


Hmm. It seems that libgee-list <AT> gnome <DOT> org I'm currently
subscribed is non-existent ;)

I'm reading this ML regularly but I nearly missed this thread.

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

Regards

PS. Sorry for any incoherent text in this mail. 

Attachment: signature.asc
Description: This is a digitally signed message part



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