Re: [notmuch] [PATCH] Added regress option to tags iterator

Subject: Re: [notmuch] [PATCH] Added regress option to tags iterator

Date: Wed, 6 Jan 2010 10:08:54 +0100

To: Carl Worth

Cc: notmuch@notmuchmail.org

From: Ruben Pollan


On 11:39, Tue 05 Jan 10, Carl Worth wrote:
> 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 = 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 = 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.

Yes, make sense like that.


I'm not sure what to do about the iterator when is on an invalid item, if you 
reach an invalid item doing to_next should be possible to do to_previous to 
recover the last valid item? Or is better to force the user to use to_last to 
go back?

In some cases implement to_previous will need to store the previous item 
(actually I did that on the patches I sent).

-- 
Rubén Pollán  | jabber:meskio@jabber.org
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ésta es la historia de una sociedad que se hunde
y mientras cae se repite:
hasta ahora todo va bien, hasta ahora todo va bien ...
Pero lo importante no es la caida sino el aterrizaje.
                               el odio
signature.asc (application/pgp-signature)

Thread: