DocIdSetIterator接口

org.apache.lucene.search.DocIdSetIterator
package org.apache.lucene.search;

import java.io.IOException;

/**
* This abstract class defines methods to iterate over a set of
* non-decreasing doc ids.
* 提供一个访问id的迭代器的接口 。
*/
public abstract class DocIdSetIterator {
/** Returns the current document number. <p> This is invalid until {@link
#next()} is called for the first time.*/
public abstract int doc();

/** Moves to the next docId in the set. Returns true, iff
* there is such a docId. */
public abstract boolean next() throws IOException;

/** Skips entries to the first beyond the current whose document number is
* greater than or equal to <i>target</i>. <p>Returns true iff there is such
* an entry. <p>Behaves as if written: <pre>
* boolean skipTo(int target) {
* do {
* if (!next())
* return false;
* } while (target > doc());
* return true;
* }
* </pre>
* Some implementations are considerably more efficient than that.
* 一般的迭代器中id是升序排列 ,调用此方法达到的效果是不断的调用next()方法,直到当前的id>=target 参数停止
*/
public abstract boolean skipTo(int target) throws IOException;
}
posted @ 2011-04-07 17:23  xiao晓  阅读(639)  评论(0编辑  收藏  举报