[Xapian-discuss] Howto use the term iterator?

James Aylett james-xapian at tartarus.org
Fri Oct 3 12:30:42 BST 2008


On Fri, Oct 03, 2008 at 11:05:44AM +0100, John Wards wrote:

> The issue is that foreach needs to know when it hits the end of the
> loop. Is there anyway of a TermIterator knowing its the end? I've had a
> look at the api and I can't figure it out. I can get the end
> TermIterator from the Document but I can't use that if I want to do a
> true foreach. I suppose I could pass the end iterator when I call
> termlist_begin() but I'd rather use in-build xapian calls.

You have to use termlist_end(), as you've deduced. The Python bindings
(for instance) provide Pythonic iterators by storing the _end() as
well as initialising themselves to the _begin() so they can figure out
when to stop.

J

-- 
/--------------------------------------------------------------------------\
  James Aylett                                                  xapian.org
  james at tartarus.org                               uncertaintydivision.org



More information about the Xapian-discuss mailing list