List of usage examples for java.lang Iterable Iterable
Iterable
From source file:net.sf.maltcms.chromaui.project.spi.descriptors.CachingChromatogram1D.java
@Override public Iterable<IScan1D> subsetByMsLevel(final short msLevel) { Iterable<IScan1D> iterable = new Iterable<IScan1D>() { @Override//from w w w. j a v a 2 s . c o m public Iterator<IScan1D> iterator() { return new Scan1DIterator(msLevel); } }; return iterable; }
From source file:com.healthmarketscience.jackcess.Cursor.java
/** * Returns an Iterable whose iterator() method returns the result of a call * to {@link #iterator(Collection)}/*w ww . j a v a2s . c om*/ * @throws IllegalStateException if an IOException is thrown by one of the * operations, the actual exception will be contained within */ public Iterable<Map<String, Object>> iterable(final Collection<String> columnNames) { return new Iterable<Map<String, Object>>() { public Iterator<Map<String, Object>> iterator() { return Cursor.this.iterator(columnNames); } }; }
From source file:com.github.jsonj.JsonArray.java
/** * Convenience method to prevent casting JsonElement to JsonArray when iterating in the common case that you have * an array of JsonArrays.//from w w w . j ava 2 s . c o m * * @return iterable that iterates over JsonArrays instead of JsonElements. */ public Iterable<JsonArray> arrays() { final JsonArray parent = this; return new Iterable<JsonArray>() { @Override public Iterator<JsonArray> iterator() { final Iterator<JsonElement> iterator = parent.iterator(); return new Iterator<JsonArray>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public JsonArray next() { return iterator.next().asArray(); } @Override public void remove() { iterator.remove(); } }; } }; }
From source file:edu.byu.nlp.crowdsourcing.models.gibbs.BlockCollapsedMultiAnnModelMath.java
public static Iterable<Prediction> predictions(final Dataset data, final int y[], final Map<String, Integer> instanceMap) { return new Iterable<Prediction>() { @Override/*from w w w. jav a2 s .c o m*/ public Iterator<Prediction> iterator() { return new Iterator<Prediction>() { // only predict on unlabeled portion of dataset; the labeled portion is known private Iterator<DatasetInstance> it = data.iterator(); @Override public boolean hasNext() { return it.hasNext(); } @Override public Prediction next() { DatasetInstance instance = it.next(); // prediction based on most recent sample Integer prediction = null; if (instanceMap.containsKey(instance.getInfo().getRawSource())) { prediction = y[instanceMap.get(instance.getInfo().getRawSource())]; } return new BasicPrediction(prediction, instance); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:ezbake.services.graph.TitanGraphStore.java
@Override public Iterable<Vertex> queryVertices(String graphName, ezbake.services.graph.thrift.types.Vertex startVertex, String gremlinQuery, String authorizations) throws InvalidQueryException { final SecureTitanTx<AccumuloSecurityToken> tx = startReadTransaction(graphName, authorizations); final GremlinGroovyPipeline pipeline = queryHelper(gremlinQuery); pipeline.setStarts(//from w ww .j a v a 2 s.co m new SingleIterator<Vertex>(tx.getVertex(startVertex.getId().getTitanId().getVertexId()))); final Iterator<Vertex> vertexIterator = pipeline.iterator(); return new Iterable<Vertex>() { @Override public Iterator<Vertex> iterator() { return vertexIterator; } }; }
From source file:ezbake.services.graph.TitanGraphStore.java
@Override public Iterable<Edge> queryEdges(String graphName, ezbake.services.graph.thrift.types.Vertex startVertex, String gremlinQuery, String authorizations) throws InvalidQueryException { final SecureTitanTx<AccumuloSecurityToken> tx = startReadTransaction(graphName, authorizations); final GremlinGroovyPipeline pipeline = queryHelper(gremlinQuery); pipeline.setStarts(/*from ww w . j av a2s . c o m*/ new SingleIterator<Vertex>(tx.getVertex(startVertex.getId().getTitanId().getVertexId()))); final Iterator<Edge> edgeIterator = pipeline.iterator(); return new Iterable<Edge>() { @Override public Iterator<Edge> iterator() { return edgeIterator; } }; }
From source file:com.github.jsonj.JsonArray.java
/** * Convenience method to prevent casting JsonElement to String when iterating in the common case that you have * an array of strings.//from ww w . j a va 2s.co m * * @return iterable that iterates over Strings instead of JsonElements. */ public Iterable<String> strings() { final JsonArray parent = this; return new Iterable<String>() { @Override public Iterator<String> iterator() { final Iterator<JsonElement> iterator = parent.iterator(); return new Iterator<String>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public String next() { return iterator.next().asString(); } @Override public void remove() { iterator.remove(); } }; } }; }
From source file:edu.oregonstate.eecs.mcplan.util.Fn.java
@SafeVarargs public static <T> Iterable<T> concat(final Iterable<T>... iterables) { return new Iterable<T>() { @Override//www . jav a2s. c om public Iterator<T> iterator() { return new ConcatIterator<>(iterables); } }; }
From source file:com.quinsoft.zeidon.standardoe.EntityInstanceImpl.java
Iterable<AttributeDef> getNonNullAttributeList() { return new Iterable<AttributeDef>() { @Override/* w ww . j a va 2s . co m*/ public Iterator<AttributeDef> iterator() { return new Iterator<AttributeDef>() { private int attributeNumber = -1; private int nextAttributeNumber = -1; @Override public boolean hasNext() { if (nextAttributeNumber <= attributeNumber) { nextAttributeNumber = attributeNumber + 1; while (nextAttributeNumber < getEntityDef().getAttributeCount()) { AttributeDef attributeDef = getEntityDef().getAttribute(nextAttributeNumber); AttributeValue attrib = getInternalAttribute(attributeDef); if (!attrib.isNull(getTask(), attributeDef) || attrib.isUpdated()) break; nextAttributeNumber++; } } return nextAttributeNumber < getEntityDef().getAttributeCount(); } @Override public AttributeDef next() { attributeNumber = nextAttributeNumber; return getEntityDef().getAttribute(attributeNumber); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; }