Re: Proposal for a collection API in glib
- From: Sebastian Rittau <srittau jroger in-berlin de>
- To: gtk-devel-list gnome org
- Subject: Re: Proposal for a collection API in glib
- Date: Fri, 18 Jul 2008 15:22:00 +0200
On Thu, Jul 17, 2008 at 05:51:24PM +0200, Philip Van Hoof wrote:
> I would like to propose this API to go into glib/gio:
>
> http://live.gnome.org/IteratorsAPI
I'd like to point to my comment on that page: Please make the Iterator
interface derive from the Iterable interface, where the iterator()
function should just return the object itself. I've explained the point
in detail in [1], but here is a short summary: Often you'd like to
iterate an object in different orders, for example a Tree class that
might be iterated depth-first or breath-first. In that case it's not
enough to just make Tree implement the Iterable interface, you also need
to have two functions "DepthFirstIterator" and "BreathFirstIterator". If
Iterators are Iterable, you can just use the returned iterator like you
would use the Tree object itself. If they aren't you'd need to return a
custom Iterable object (which implements an Iterator).
- Sebastian
[1] http://www.rittau.org/blog/20061122-00
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]