Example usage for org.apache.commons.collections.iterators CollatingIterator CollatingIterator

List of usage examples for org.apache.commons.collections.iterators CollatingIterator CollatingIterator

Introduction

In this page you can find the example usage for org.apache.commons.collections.iterators CollatingIterator CollatingIterator.

Prototype

public CollatingIterator(final Comparator comp, final Collection iterators) 

Source Link

Document

Constructs a new CollatingIterator that will use the specified comparator to provide ordered iteration over the collection of iterators.

Usage

From source file:org.apache.cassandra.db.compaction.LazilyCompactedRow.java

public Iterator<IColumn> iterator() {
    for (SSTableIdentityIterator row : rows) {
        row.reset();//from   w  ww.ja v  a  2s  . co  m
    }
    reducer = new LazyColumnIterator(new CollatingIterator(getComparator().columnComparator, rows));
    return Iterators.filter(reducer, Predicates.notNull());
}

From source file:org.apache.cassandra.io.LazilyCompactedRow.java

public Iterator<IColumn> iterator() {
    for (SSTableIdentityIterator row : rows) {
        row.reset();/* w w  w  .j  a  v  a 2s  .com*/
    }
    iter = new LazyColumnIterator(new CollatingIterator(getComparator().columnComparator, rows));
    return Iterators.filter(iter, Predicates.notNull());
}

From source file:org.apache.sling.contextaware.config.resource.impl.ContextPathStrategyMultiplexer.java

/**
 * Merges results from different context path strategy implementations.
 * Eliminating of duplicates and sorting is done solely based on path length.
 * The contract of the ContextPathStrategy defines that only parents or the resource itself
 * is returned, so the assumption should be safe.
 * @param allResults List of all results
 * @return Merged result// ww w  .java2  s.co m
 */
@SuppressWarnings("unchecked")
private Iterator<Resource> mergeResults(List<Iterator<Resource>> allResults) {
    return new FilterIterator(new CollatingIterator(PATH_LENGTH_COMPARATOR, allResults),
            // eliminate duplicate resources reported by different implementations
            new Predicate() {
                private Set<String> resourcePaths = new HashSet<>();

                @Override
                public boolean evaluate(Object object) {
                    return resourcePaths.add(((Resource) object).getPath());
                }
            });
}