com.browseengine.bobo.util.SearchResultMerger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bobo-browse Show documentation
Show all versions of bobo-browse Show documentation
Bobo is a Faceted Search implementation written purely in Java, an extension of Apache Lucene
The newest version!
package com.browseengine.bobo.util;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.apache.lucene.util.PriorityQueue;
public class SearchResultMerger {
private SearchResultMerger() {
}
public static class MergedIterator implements Iterator {
private class IteratorCtx {
public Iterator _iterator;
public T _curVal;
public IteratorCtx(Iterator iterator) {
_iterator = iterator;
_curVal = null;
}
public boolean fetch() {
if (_iterator.hasNext()) {
_curVal = _iterator.next();
return true;
}
_curVal = null;
return false;
}
}
@SuppressWarnings("rawtypes")
private final PriorityQueue _queue;
@SuppressWarnings("unchecked")
public MergedIterator(final List> sources, final Comparator comparator) {
_queue = new PriorityQueue