Example usage for com.google.common.collect Iterators concat

List of usage examples for com.google.common.collect Iterators concat

Introduction

In this page you can find the example usage for com.google.common.collect Iterators concat.

Prototype

public static <T> Iterator<T> concat(final Iterator<? extends Iterator<? extends T>> inputs) 

Source Link

Document

Combines multiple iterators into a single iterator.

Usage

From source file:org.apache.crunch.impl.mem.CountersWrapper.java

@Override
public Iterator<CounterGroup> iterator() {
    return Iterators.concat(Iterables.transform(allCounters, new Function<Counters, Iterator<CounterGroup>>() {
        @Override// ww w . jav a 2  s .c o  m
        public Iterator<CounterGroup> apply(Counters input) {
            return input.iterator();
        }
    }).iterator());
}

From source file:org.optaplanner.core.impl.domain.valuerange.buildin.composite.CompositeCountableValueRange.java

@Override
public Iterator<T> createOriginalIterator() {
    List<Iterator<T>> iteratorList = new ArrayList<Iterator<T>>(childValueRangeList.size());
    for (CountableValueRange<T> childValueRange : childValueRangeList) {
        iteratorList.add(childValueRange.createOriginalIterator());
    }// w  w  w.j a v a 2  s .com
    return Iterators.concat(iteratorList.iterator());
}

From source file:org.fcrepo.kernel.modeshape.rdf.impl.VersionsRdfContext.java

@SuppressWarnings("unchecked")
private Iterator<Triple> versionTriples() throws RepositoryException {
    final Iterator<Version> allVersions = versionHistory.getAllVersions();
    return Iterators.concat(Iterators.transform(allVersions, version2triples::apply));
}

From source file:org.jclouds.collect.PagedIterable.java

/**
 * Combines all the pages into a single unmodifiable iterable. ex.
 * //from  w  w  w .  j a  v a2  s  . c o m
 * <pre>
 * FluentIterable<StorageMetadata> blobs = blobstore.list(...).concat();
 * for (StorageMetadata blob : blobs) {
 *     process(blob);
 * }
 * </pre>
 * 
 * @see Iterators#concat
 */
public FluentIterable<E> concat() {
    final Iterator<IterableWithMarker<E>> iterator = iterator();
    final UnmodifiableIterator<Iterator<E>> unmodifiable = new UnmodifiableIterator<Iterator<E>>() {
        @Override
        public boolean hasNext() {
            return iterator.hasNext();
        }

        @Override
        public Iterator<E> next() {
            return iterator.next().iterator();
        }
    };
    return new FluentIterable<E>() {
        @Override
        public Iterator<E> iterator() {
            return Iterators.concat(unmodifiable);
        }
    };
}

From source file:org.sonar.javascript.model.implementations.expression.ObjectLiteralTreeImpl.java

@Override
public Iterator<Tree> childrenIterator() {
    return Iterators.concat(properties.iterator());
}

From source file:com.eucalyptus.reporting.export.ReportingExport.java

private <T> Iterator<T> iterateAll(Iterable<Iterable<T>> data) {
    List<Iterator<T>> iterators = Lists.newArrayList();
    for (final Iterable<T> iterable : data) {
        iterators.add(iterable.iterator());
    }/*w  ww.ja v  a 2s  .  co  m*/
    return Iterators.unmodifiableIterator(Iterators.concat(iterators.iterator()));
}

From source file:org.sonar.javascript.model.implementations.declaration.ArrayBindingPatternTreeImpl.java

@Override
public Iterator<Tree> childrenIterator() {
    List<Tree> nonElidedElements = Lists.newArrayList();
    for (Optional<BindingElementTree> e : elements) {
        if (e.isPresent()) {
            nonElidedElements.add(e.get());
        }/*from   ww  w.ja v  a  2s .  com*/
    }
    return Iterators.concat(nonElidedElements.iterator());
}

From source file:org.apache.kylin.storage.gtrecord.StorageResponseGTScatter.java

@Override
public Iterator<GTRecord> iterator() {
    Iterator<PartitionResultIterator> iterators = Iterators.transform(blocks,
            new Function<byte[], PartitionResultIterator>() {
                public PartitionResultIterator apply(byte[] input) {
                    return new PartitionResultIterator(input, info, columns);
                }/*from   w w  w.j a  v a  2  s .  c  o m*/
            });

    if (!needSorted) {
        logger.debug("Using Iterators.concat to pipeline partition results");
        return Iterators.concat(iterators);
    }

    List<PartitionResultIterator> partitionResults = Lists.newArrayList(iterators);
    if (partitionResults.size() == 1) {
        return partitionResults.get(0);
    }
    logger.debug("Using SortMergedPartitionResultIterator to merge {} partition results",
            partitionResults.size());
    return new SortMergedPartitionResultIterator(partitionResults, info, GTRecord.getComparator(groupByDims));
}

From source file:org.eclipse.sirius.ext.base.collect.MultipleCollection.java

/**
 * /*from  w w w .j av a  2s.  c  om*/
 * {@inheritDoc}
 */
public Iterator<E> iterator() {
    if (sets.size() > 0) {
        final List<Iterator<? extends E>> iterators = new ArrayList<Iterator<? extends E>>();
        for (final Collection<? extends E> col : sets) {
            iterators.add(col.iterator());
        }
        return Iterators.concat(iterators.iterator());
    } else {
        return new ArrayList().iterator();
    }
}

From source file:org.apache.jackrabbit.oak.spi.security.principal.CompositePrincipalProvider.java

@Nonnull
@Override/*from www .j av a  2s  . c o m*/
public Iterator<Principal> findPrincipals(@Nullable String nameHint, int searchType) {
    Iterator<? extends Principal>[] iterators = new Iterator[providers.size()];
    int i = 0;
    for (PrincipalProvider provider : providers) {
        if (nameHint == null) {
            iterators[i++] = provider.findPrincipals(searchType);
        } else {
            iterators[i++] = provider.findPrincipals(nameHint, searchType);
        }
    }
    return Iterators.concat(iterators);
}