olly at survex.com
Thu May 17 00:33:54 BST 2012
On Wed, May 16, 2012 at 06:57:34PM +0400, Michael Uvarov wrote:
> Is there way to clone iterators?
> Something like this:
> Xapian::TermIterator x(y); // or x = y
> // Can we change x independently of y?
> // No, we can not. y was also modified.
> assert(*x != *y);
The input iterators like TermIterator have the standard C++
input iterator semantics, so advancing x invalidates y. There's not
a direct way to clone an iterator - you'd have to get a fresh one from
the parent object and call skip_to() on it to advance it to the same
The bidirectional iterators (like MSetIterator and ESetIterator) can
be cloned just by making a copy.
More information about the Xapian-devel