| 1 | |
|
| 2 | |
package org.galagosearch.core.retrieval.structured; |
| 3 | |
|
| 4 | |
import org.galagosearch.core.util.ExtentArray; |
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | 4 | public class ExtentArrayIterator implements Comparable<ExtentArrayIterator> { |
| 11 | |
ExtentArray array; |
| 12 | |
int index; |
| 13 | |
|
| 14 | 104 | public ExtentArrayIterator(ExtentArray array) { |
| 15 | 104 | this.array = array; |
| 16 | 104 | } |
| 17 | |
|
| 18 | |
public Extent current() { |
| 19 | 268 | return array.getBuffer()[index]; |
| 20 | |
} |
| 21 | |
|
| 22 | |
public boolean next() { |
| 23 | 88 | index += 1; |
| 24 | 88 | return index < array.getPosition(); |
| 25 | |
} |
| 26 | |
|
| 27 | |
public boolean isDone() { |
| 28 | 80 | return array.getPosition() <= index; |
| 29 | |
} |
| 30 | |
|
| 31 | |
public int compareTo(ExtentArrayIterator iterator) { |
| 32 | 4 | int result = current().document - iterator.current().document; |
| 33 | |
|
| 34 | 4 | if (result != 0) { |
| 35 | 0 | return result; |
| 36 | |
} |
| 37 | 4 | return current().begin - iterator.current().begin; |
| 38 | |
} |
| 39 | |
} |