Example usage for org.apache.commons.collections4 IteratorUtils chainedIterator

List of usage examples for org.apache.commons.collections4 IteratorUtils chainedIterator

Introduction

In this page you can find the example usage for org.apache.commons.collections4 IteratorUtils chainedIterator.

Prototype

public static <E> Iterator<E> chainedIterator(final Collection<Iterator<? extends E>> iterators) 

Source Link

Document

Gets an iterator that iterates through a collections of Iterator s one after another.

Usage

From source file:com.tussle.hitbox.HitboxComponent.java

public Collection<Hitbox> getHitboxes() {
    if (hitboxValues == null) {
        hitboxValues = new AbstractCollection<Hitbox>() {
            public Iterator<Hitbox> iterator() {
                return IteratorUtils
                        .chainedIterator(CollectionUtils.collect(hitboxes.values(), HashSet::iterator));
            }//from   w  w  w  .  j av a  2s  .  c  o m

            public int size() {
                //WHEE JAVA FUNCTIONAL STREAMS
                return hitboxes.values().stream().mapToInt(HashSet::size).sum();
            }
        };
    }
    return hitboxValues;
}

From source file:com.tussle.hitbox.HurtboxComponent.java

public Collection<Hurtbox> getHurtboxes() {
    if (hurtboxValues == null) {
        hurtboxValues = new AbstractCollection<Hurtbox>() {
            public Iterator<Hurtbox> iterator() {
                return IteratorUtils
                        .chainedIterator(CollectionUtils.collect(hurtboxes.values(), HashSet::iterator));
            }//from w  w w .j  av  a 2  s .c o m

            public int size() {
                //WHEE JAVA FUNCTIONAL STREAMS
                return hurtboxes.values().stream().mapToInt(HashSet::size).sum();
            }
        };
    }
    return hurtboxValues;
}

From source file:com.tussle.collision.StageElementComponent.java

public Collection<StageElement> getStageElements() {
    if (hitboxValues == null) {
        hitboxValues = new AbstractCollection<StageElement>() {
            public Iterator<StageElement> iterator() {
                return IteratorUtils
                        .chainedIterator(CollectionUtils.collect(surfaces.values(), HashSet::iterator));
            }//  w  w  w .j  a  v a2  s . c o  m

            public int size() {
                //WHEE JAVA FUNCTIONAL STREAMS
                return surfaces.values().stream().mapToInt(HashSet::size).sum();
            }
        };
    }
    return hitboxValues;
}

From source file:com.tussle.collision.ECBComponent.java

public Collection<StageElement<CollisionStadium>> getCollisionBoxes() {
    if (hitboxValues == null) {
        hitboxValues = new AbstractCollection<StageElement<CollisionStadium>>() {
            public Iterator<StageElement<CollisionStadium>> iterator() {
                return IteratorUtils.chainedIterator(CollectionUtils.collect(ecbs.values(), HashSet::iterator));
            }//  www .  j a  v  a2 s .c  om

            public int size() {
                //WHEE JAVA FUNCTIONAL STREAMS
                return ecbs.values().stream().mapToInt(HashSet::size).sum();
            }
        };
    }
    return hitboxValues;
}

From source file:com.link_intersystems.lang.reflect.criteria.JavaElementTraverseStrategies.java

public Iterator<?> getIterator(Class<?> currentClass, ElementCriteria elementCriteria) {
    List<Iterator<?>> iterators = new ArrayList<Iterator<?>>();
    for (int i = 0; i < javaElementTraverseStrategies.length; i++) {
        JavaElementTraverseStrategy javaElementTraverseStrategy = javaElementTraverseStrategies[i];
        Iterator<?> iterator = javaElementTraverseStrategy.getIterator(currentClass, elementCriteria);
        iterators.add(iterator);/*w w  w  . j a  v a 2  s.  co m*/
    }
    return IteratorUtils.chainedIterator(iterators);
}

From source file:com.yahoo.bard.webservice.util.SimplifiedIntervalList.java

/**
 * Create an Iterator using IntervalPeriodInterators to all intervals of this list broken up into pieces of size
 * period./*ww  w. ja  v  a  2  s  .c om*/
 *
 * @param readablePeriod  The period to chunk subintervals into.
 *
 * @return An iterator which returns period sized subintervals of this interval list.
 */
public Iterator<Interval> periodIterator(ReadablePeriod readablePeriod) {
    List<Iterator<? extends Interval>> periodIterators = this.stream()
            .map(e -> new IntervalPeriodIterator(readablePeriod, e)).collect(Collectors.toList());
    return IteratorUtils.chainedIterator(periodIterators);
}