Example usage for java.lang Iterable iterator

List of usage examples for java.lang Iterable iterator

Introduction

In this page you can find the example usage for java.lang Iterable iterator.

Prototype

Iterator<T> iterator();

Source Link

Document

Returns an iterator over elements of type T .

Usage

From source file:jef.tools.collection.CollectionUtils.java

/**
 * Iterable?List//  w ww  .  j  av  a 2 s.  co  m
 * 
 * @param data
 * @return ??List
 */
public static <E> List<E> toList(Iterable<E> data) {
    List<E> result = new ArrayList<E>();
    for (Iterator<E> iter = data.iterator(); iter.hasNext();) {
        result.add(iter.next());
    }
    return result;
}

From source file:jef.tools.collection.CollectionUtils.java

/**
 * Check whether the given Iterator contains the given element.
 * //  w  ww .  j a  v a  2 s .  c  om
 * @param iterator
 *            the Iterator to check
 * @param element
 *            the element to look for
 * @return <code>true</code> if found, <code>false</code> else
 */
public static boolean contains(Iterable<?> iterable, Object element) {
    if (iterable != null) {
        Iterator<?> iterator = iterable.iterator();
        while (iterator.hasNext()) {
            Object candidate = iterator.next();
            if (Objects.equal(candidate, element)) {
                return true;
            }
        }
    }
    return false;
}

From source file:com.buaa.cfs.utils.StringUtils.java

/**
 * Concatenates strings, using a separator.
 *
 * @param separator Separator to join with.
 * @param strings   Strings to join.//from w w w  .j  a  v  a 2  s  .com
 */
public static String join(CharSequence separator, Iterable<?> strings) {
    Iterator<?> i = strings.iterator();
    if (!i.hasNext()) {
        return "";
    }
    StringBuilder sb = new StringBuilder(i.next().toString());
    while (i.hasNext()) {
        sb.append(separator);
        sb.append(i.next().toString());
    }
    return sb.toString();
}

From source file:net.longfalcon.newsj.nntp.client.ArticleIterator.java

public ArticleIterator(Iterable<String> iterableString) {
    stringIterator = iterableString.iterator();
}

From source file:org.apache.geode.geospatial.grid.IndexHAMaintenance.java

@Override
public void afterBucketRemoved(int bucketId, Iterable<?> keys) {
    Iterator<?> it = keys.iterator();
    it.forEachRemaining(key -> geospatialIndex.remove(key));
}

From source file:org.openbaton.vnfm.repositories.ManagedVNFRRepositoryImpl.java

@Override
public void deleteByVnfrId(String vnfrId) throws NotFoundException {
    Iterable<ManagedVNFR> entities = findByVnfrId(vnfrId);
    if (!entities.iterator().hasNext()) {
        throw new NotFoundException("Not found any VNFR with id: " + vnfrId + "managed by this VNFM");
    } else {//from ww  w . jav a 2  s.  c o  m
        managedVNFRRepository.delete(entities);
    }
}

From source file:com.insightml.data.features.stats.AbstractFeatureStatsTest.java

@Test
@Ignore/* ww w . j a  v  a 2  s  .  co  m*/
public final void test() {
    for (final Pair<IDataset<?, ?, ?>, ObjectiveFunction[]> dataset : TestDatasets.createInstances()) {
        final Iterable<? extends Sample> inst = dataset.getFirst().loadAll();
        if (!(inst.iterator().next().getExpected(0) instanceof String)) {
            test(((IDataset) dataset.getFirst()).pipeline().run(inst, true));
        }
    }
}

From source file:org.arrow.runtime.mapper.AppendMessageMapper.java

/**
 * {@inheritDoc}//from  ww  w .j av  a 2  s. co m
 */
@Override
public Iterable<EventMessage> apply(Iterable<EventMessage> parameter) {
    Iterator<EventMessage> iterator = parameter.iterator();
    List<EventMessage> list = IteratorUtil.asList(iterator);

    Collections.addAll(list, messages);
    return list;
}

From source file:de.dhke.projects.cutil.collections.iterator.ChainIterable.java

@Override
public Iterator<E> iterator() {
    final Collection<Iterator<? extends E>> iterCollection = ExtractorCollection.decorate(_iterableList,
            new Transformer<Iterable<? extends E>, Iterator<? extends E>>() {
                @Override//from   w  w  w.  j av a  2 s . c om
                public Iterator<? extends E> transform(Iterable<? extends E> input) {
                    return input.iterator();
                }
            });
    return ChainIterator.decorate(iterCollection);
}

From source file:de.msg.repository.RouteRepositoryTest.java

@Test
public void findByDeparture() throws Exception {
    Iterable<Route> actual = repository.findByDeparture("FRA");
    Assert.assertNotNull(actual.iterator().hasNext());
}