/* Optimized scan, without allocating new terms.
* Return number of invocations to next().
*
* NOTE: LUCENE-3183: if you pass Term("", "") here then this
* will incorrectly return before positioning the enum,
* and position will be -1; caller must detect this. */
internal int ScanTo(Term term)
{
scanBuffer.Set(term);
int count = 0;
if (first)
{
// Always force initial next() in case term is
// Term("", "")
Next();
first = false;
count++;
}
while (scanBuffer.CompareTo(termBuffer) > 0 && Next())
{
count++;
}
return(count);
}