All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pingbu.search.MultiIterator Maven / Gradle / Ivy

The newest version!
package pingbu.search;

import java.util.List;

class MultiIterator implements SearchIndex.Iterator {
    private final List mIterators;

    public MultiIterator(final List iterators) {
        mIterators = iterators;
    }

    @Override
    public int getNextItem() {
        int id = Integer.MAX_VALUE;
        for (final SearchIndex.Iterator iterator : mIterators)
            id = Math.min(id, iterator.getNextItem());
        return id;
    }

    @Override
    public double sumUpToItem(final int id) {
        double score = 0;
        for (final SearchIndex.Iterator iterator : mIterators)
            score = Math.max(score, iterator.sumUpToItem(id));
        return score;
    }

    @Override
    public void close() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy