From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 7279B431FC2; Tue, 5 Jan 2010 11:59:36 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P8dSZRvGJFHo; Tue, 5 Jan 2010 11:59:36 -0800 (PST) Received: from yoom.home.cworth.org (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id DE5D9431FBD; Tue, 5 Jan 2010 11:59:35 -0800 (PST) Received: by yoom.home.cworth.org (Postfix, from userid 1000) id 0A9472540F8; Tue, 5 Jan 2010 11:39:20 -0800 (PST) From: Carl Worth To: Ruben Pollan In-Reply-To: <20100105153332.GE9339@blackspot> References: <20091126202347.GA16654@blackspot> <1260364206-344-1-git-send-email-meskio@sindominio.net> <20091209132446.GC23878@blackspot> <877hsv6hbo.fsf@yoom.home.cworth.org> <87r5qnol78.fsf@yoom.home.cworth.org> <87pr67ofz2.fsf@yoom.home.cworth.org> <20100105153332.GE9339@blackspot> Date: Tue, 05 Jan 2010 11:39:14 -0800 Message-ID: <87637gnxy5.fsf@yoom.home.cworth.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Cc: notmuch@notmuchmail.org Subject: Re: [PATCH] Added regress option to tags iterator X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jan 2010 19:59:36 -0000 --=-=-= Content-Transfer-Encoding: quoted-printable On Tue, 5 Jan 2010 16:33:32 +0100, Ruben Pollan wro= te: > Not sure if I understand that. Let's see if I understand well. move_to_fi= rst > (or move_to_last) will put the iterator in the first (or last) valid item. > move_to_next (and move_to_previous) will be able to reach an invalid item > outside the list. Is it like that? Yes, that's the idea. > In some implementations of iterators (like C++ STD) you can reach invalid= items > only in one side of the list, at the end, but not at the beginning. Some = people > get use to this idea, but should not be a big deal to do it different. Yes, I've seen interfaces like that. They don't make sense to me since then one direction or the other is much harder to iterate, (the interface won't afford an easy for-loop-based iteration for example). > So you are thinking in a function has_current showing if the current item= is > valid. Am I right? Right. So example code using this would be: for (notmuch_messages_to_first (messages); notmuch_messages_has_current (messages); notmuch_messages_to_next (messages)) { notmuch_message_t *message; message =3D notmuch_messages_get_current (messages); ... } And for iterating in the opposite direction it's very similar: for (notmuch_messages_to_last (messages); notmuch_messages_has_current (messages); notmuch_messages_to_previous (messages)) { notmuch_message_t *message; message =3D notmuch_messages_get_current (messages); ... } Note that if you couldn't get the iterator to point to an invalid item before the first, then this second loop would have to look very different. > I think that's a good option. The names of the functions are still clear = like > that, and the original names are too long. >=20 > PS: Sorry for the late reply, Christmas is a busy time. Thanks for the feedback. And no worries about the late reply---I've been quite busy myself. =2DCarl --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iD8DBQFLQ5Vi6JDdNq8qSWgRAv+qAKCTx4G8cCg2MxzoHiokXzlTuFLyfgCfUjEo Z1RKLLAE4Wzl0XZm6VgFu40= =EMEo -----END PGP SIGNATURE----- --=-=-=--