Java 类org.apache.commons.collections4.iterators.FilterIterator 实例源码

项目:bifroest    文件:MetricSet.java   
@Override
public Iterator<Metric> iterator() {
    return new FilterIterator<>(
            new Iterator<Metric>() {
                private int nextIndex;

                @Override
                public boolean hasNext() {
                    return nextIndex < values.length;
                }

                @Override
                public Metric next() {
                    Metric ret = new Metric( name, startTimestamp + nextIndex * step, values[nextIndex] );
                    nextIndex++;
                    return ret;
                }
            }, metric -> !Double.isNaN( metric.value() ) );
}
项目:bifroest    文件:GetValueCommand.java   
private Iterable<Metric> getMetrics( E environment, String name, Interval interval ) {
    return new Iterable<Metric>() {
        @Override
        public Iterator<Metric> iterator() {
            return new FilterIterator<>( _getMetrics( environment, name, interval ).iterator(), metric -> interval.contains( metric.timestamp() ) );
        }
    };
}
项目:gatk-protected    文件:AbstractConcordanceWalker.java   
private Spliterator<TruthVersusEval> getSpliteratorForDrivingVariants() {
    final Iterator<VariantContext> truthIterator = new FilterIterator<>(truthVariants.iterator(), makeTruthVariantFilter());
    final Iterator<VariantContext> evalIterator = new FilterIterator<>(evalVariants.iterator(), makeEvalVariantFilter());
    return new ConcordanceIterator(truthIterator, evalIterator).spliterator();
}
项目:crigtt    文件:CrigttIteratorUtils.java   
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
public static <T, U> FilterIterator<U> instances(Iterator<T> iterator, Class<U> clazz) {
    return ((FilterIterator<U>) IteratorUtils.filteredIterator(iterator, PredicateUtils.instanceofPredicate(clazz)));
}
项目:gatk    文件:AbstractConcordanceWalker.java   
private Spliterator<TruthVersusEval> getSpliteratorForDrivingVariants() {
    final Iterator<VariantContext> truthIterator = new FilterIterator<>(truthVariants.iterator(), makeTruthVariantFilter());
    final Iterator<VariantContext> evalIterator = new FilterIterator<>(evalVariants.iterator(), makeEvalVariantFilter());
    return new ConcordanceIterator(truthIterator, evalIterator).spliterator();
}
项目:HCFCore    文件:IteratorUtils.java   
/**
 * Gets an iterator that filters another iterator.
 * <p>
 * The returned iterator will only return objects that match the specified
 * filtering predicate.
 *
 * @param <E> the element type
 * @param iterator  the iterator to use, not null
 * @param predicate  the predicate to use as a filter, not null
 * @return a new filtered iterator
 * @throws NullPointerException if either parameter is null
 */
public static <E> Iterator<E> filteredIterator(final Iterator<? extends E> iterator,
                                               final Predicate<? super E> predicate) {
    if (iterator == null) {
        throw new NullPointerException("Iterator must not be null");
    }
    if (predicate == null) {
        throw new NullPointerException("Predicate must not be null");
    }
    return new FilterIterator<E>(iterator, predicate);
}
项目:HCFCore    文件:IteratorUtils.java   
/**
 * Gets an iterator that filters another iterator.
 * <p>
 * The returned iterator will only return objects that match the specified
 * filtering predicate.
 *
 * @param <E> the element type
 * @param iterator  the iterator to use, not null
 * @param predicate  the predicate to use as a filter, not null
 * @return a new filtered iterator
 * @throws NullPointerException if either parameter is null
 */
public static <E> Iterator<E> filteredIterator(final Iterator<? extends E> iterator,
                                               final Predicate<? super E> predicate) {
    if (iterator == null) {
        throw new NullPointerException("Iterator must not be null");
    }
    if (predicate == null) {
        throw new NullPointerException("Predicate must not be null");
    }
    return new FilterIterator<E>(iterator, predicate);
}