List of usage examples for java.lang Iterable Iterable
Iterable
From source file:edu.dfci.cccb.mev.deseq.domain.simple.FileBackedDESeq.java
private Iterable<Entry> iterateEntries(final File file) { return new Iterable<Entry>() { /* (non-Javadoc) * @see java.lang.Iterable#iterator() */ @Override/*from w w w . j a va 2s . c o m*/ @SneakyThrows(IOException.class) public Iterator<Entry> iterator() { return new Iterator<Entry>() { private final BufferedReader reader = new BufferedReader(new FileReader(file)); private String current = null; @Override @Synchronized @SneakyThrows(IOException.class) public boolean hasNext() { return current == null ? (current = reader.readLine()) != null : true; } @Override @Synchronized public Entry next() { hasNext(); Entry result = parse(current); current = null; return result; } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:it.unibo.alchemist.language.protelis.datatype.FieldTroveMapImpl.java
@Override public Iterable<DeviceUID> nodeIterator() { return new Iterable<DeviceUID>() { @Override// w ww . ja v a 2s . c om public Iterator<DeviceUID> iterator() { List<DeviceUID> list = new ArrayList<>(); for (Pair<DeviceUID, Object> e : fld.valueCollection()) { list.add(e.getFirst()); } return list.iterator(); } }; }
From source file:org.apache.flink.runtime.state.StateInitializationContextImpl.java
public StateInitializationContextImpl(boolean restored, OperatorStateStore operatorStateStore, KeyedStateStore keyedStateStore, Collection<KeyGroupsStateHandle> keyGroupsStateHandles, Collection<OperatorStateHandle> operatorStateHandles, CloseableRegistry closableRegistry) { this.restored = restored; this.closableRegistry = Preconditions.checkNotNull(closableRegistry); this.operatorStateStore = operatorStateStore; this.keyedStateStore = keyedStateStore; this.operatorStateHandles = operatorStateHandles; this.keyGroupsStateHandles = keyGroupsStateHandles; this.keyedStateIterable = keyGroupsStateHandles == null ? null : new Iterable<KeyGroupStatePartitionStreamProvider>() { @Override/*from w w w. j a v a 2 s .c o m*/ public Iterator<KeyGroupStatePartitionStreamProvider> iterator() { return new KeyGroupStreamIterator(getKeyGroupsStateHandles().iterator(), getClosableRegistry()); } }; }
From source file:org.omnaest.utils.structure.iterator.IterableUtils.java
/** * Returns a new {@link Iterable} instance for the given one which will return a circular {@link Iterator}. The {@link Iterator} * will stop additionally if the given limit of cycles is reached. If no limit should be used set the parameter to -1 * //from w ww. j a v a 2 s .c o m * @see #circular(Iterable) * @param iterable * @param limit * @return */ public static <E> Iterable<E> circular(final Iterable<E> iterable, final long limit) { // Assert.isNotNull(iterable); // return new Iterable<E>() { @Override public Iterator<E> iterator() { // Factory<Iterator<E>> iteratorFactory = new Factory<Iterator<E>>() { /* ********************************************** Variables ********************************************** */ private long counter = 0; /* ********************************************** Methods ********************************************** */ @Override public Iterator<E> newInstance() { return limit < 0 || this.counter++ < limit ? iterable.iterator() : null; } }; return IteratorUtils.factoryBasedIterator(iteratorFactory); } }; }
From source file:ch.systemsx.cisd.openbis.generic.server.business.bo.common.PropertiesSetListingQueryFullTableScan.java
public Iterable<VocabularyTermRecord> getEntityPropertyVocabularyTermValues(final LongSet entityIDs) { return new Iterable<VocabularyTermRecord>() { public Iterator<VocabularyTermRecord> iterator() { return new FilterIterator<VocabularyTermRecord>(query.getEntityPropertyVocabularyTermValues(), new Predicate<BaseEntityPropertyRecord>() { public boolean evaluate(BaseEntityPropertyRecord baseSample) { return entityIDs.contains(baseSample.entity_id); }//from w w w . java 2s . co m }); } }; }
From source file:edu.dfci.cccb.mev.limma.domain.simple.FileBackedLimma.java
public Iterable<GoEntry> topGo() { return new Iterable<GoEntry>() { /* (non-Javadoc) * @see java.lang.Iterable#iterator() */ @Override//from w ww .ja v a 2 s .c om @SneakyThrows(IOException.class) public Iterator<GoEntry> iterator() { return new Iterator<GoEntry>() { private final BufferedReader reader = new BufferedReader(new FileReader(topGo)); private String current = null; /* (non-Javadoc) * @see java.util.Iterator#hasNext() */ @Override @SneakyThrows(IOException.class) public boolean hasNext() { return current == null ? (current = reader.readLine()) != null : true; } /* (non-Javadoc) * @see java.util.Iterator#next() */ @Override public GoEntry next() { hasNext(); final String[] split = current.split("\t"); GoEntry result = new GoEntry() { @Override public String term() { return string(1, split); } @Override public String significant() { return string(3, split); } @Override public double pValue() { return number(5, split); } @Override public String id() { return string(0, split); } @Override public String expected() { return string(4, split); } @Override public String annotated() { return string(2, split); } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "{id:" + id() + ", term:" + term() + ", annotated:" + annotated() + ", significant:" + significant() + ", expected:" + expected() + ", pValue:" + pValue() + "}"; } }; current = null; return result; } /* (non-Javadoc) * @see java.util.Iterator#remove() */ @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:com.emc.ecs.sync.config.ConfigUtil.java
public static Iterable<ConfigWrapper<?>> allFilterConfigWrappers() { return new Iterable<ConfigWrapper<?>>() { @Override//w ww . j av a2 s.c o m public Iterator<ConfigWrapper<?>> iterator() { return new WrapperIterator(filterScanner.findCandidateComponents("com.emc.ecs.sync").iterator()); } }; }
From source file:jef.tools.ArrayUtils.java
/** * CharSequence????char/*www . ja va2s .co m*/ * ?CharBuffer,StringBuilder,StringbufferIterator??? * * @param e * @return */ public static Iterable<Character> toIterable(final CharSequence e) { return new Iterable<Character>() { public Iterator<Character> iterator() { return new Iterator<Character>() { int n = 0; public boolean hasNext() { return n < e.length(); } public Character next() { return e.charAt(n++); } public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:fr.itinerennes.bundler.gtfs.GtfsAdvancedDao.java
public Iterable<ServiceDate> getAllServiceDates() { final ServiceDate start = getStartDate(); final ServiceDate end = getEndDate(); return new Iterable<ServiceDate>() { @Override/* w w w. jav a2s . c om*/ public Iterator<ServiceDate> iterator() { return new Iterator<ServiceDate>() { private ServiceDate next = start; @Override public boolean hasNext() { return next.compareTo(end) <= 0; } @Override public ServiceDate next() { final ServiceDate current = next; next = next.next(TimeZone.getDefault()); return current; } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:ch.entwine.weblounge.bridge.oaipmh.harvester.ListRecordsResponse.java
/** * Get all metadata performing a complete request resuming any partial * responses.//from w ww . ja v a 2 s. c o m */ public static Iterable<Node> getAllMetadataElems(final ListRecordsResponse first, final OaiPmhRepositoryClient client) { return new Iterable<Node>() { public Iterator<Node> iterator() { return new ResponseIterator(first) { @Override protected OaiPmhRepositoryClient getClient() { return client; } @Override protected NodeList extractNodes(ListRecordsResponse response) { return response.getMetadataElems(); } }; } }; }