On Tue, 5 Jan 2010 16:33:32 +0100, Ruben Pollan <meskio@sindominio.net> wrote: > Not sure if I understand that. Let's see if I understand well. move_to_first > (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 = 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. > I think that's a good option. The names of the functions are still clear like > that, and the original names are too long. > > 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. -Carl