本文整理了Java中gnu.trove.list.TIntList.forEach()
方法的一些代码示例,展示了TIntList.forEach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TIntList.forEach()
方法的具体详情如下:
包路径:gnu.trove.list.TIntList
类名称:TIntList
方法名:forEach
[英]Applies the procedure to each value in the list in ascending (front to back) order.
[中]将该过程按升序(从前到后)应用于列表中的每个值。
代码示例来源:origin: alibaba/mdrill
/**
* Executes <tt>procedure</tt> for each element in the set.
*
* @param procedure a <code>TObjectProcedure</code> value
* @return false if the loop over the set terminated because
* the procedure returned false for some value.
*/
@Override
public boolean forEach(TObjectProcedure<? super E> procedure) {
ForEachProcedure forEachProcedure = new ForEachProcedure(_set, procedure);
return order.forEach(forEachProcedure);
}
}
代码示例来源:origin: alibaba/mdrill
@Override
protected void writeEntries(ObjectOutput out) throws IOException {
// ENTRIES
WriteProcedure writeProcedure = new WriteProcedure(out);
if (!order.forEach(writeProcedure))
throw writeProcedure.getIoException();
}
代码示例来源:origin: MovingBlocks/Terasology
indices.forEach(value -> {
if (value < 0 || value >= vertices.length) {
throw new JsonParseException("Face value out of range: " + value + ", max vertex is " + (vertices.length - 1));
代码示例来源:origin: com.conveyal/r5
/** Mark patterns at touched stops, to be explored in a subsequent round */
private void markPatterns () {
this.touchedPatterns.clear();
for (int stop = touchedStops.nextSetBit(0); stop >= 0; stop = touchedStops.nextSetBit(stop + 1)) {
network.transitLayer.patternsForStop.get(stop).forEach(pat -> {
this.touchedPatterns.set(pat);
return true;
});
}
this.touchedStops.clear();
}
代码示例来源:origin: conveyal/r5
/** Mark patterns at touched stops, to be explored in a subsequent round */
private void markPatterns () {
this.touchedPatterns.clear();
for (int stop = touchedStops.nextSetBit(0); stop >= 0; stop = touchedStops.nextSetBit(stop + 1)) {
network.transitLayer.patternsForStop.get(stop).forEach(pat -> {
this.touchedPatterns.set(pat);
return true;
});
}
this.touchedStops.clear();
}
代码示例来源:origin: net.sf.trove4j/trove4j
/**
* Executes <tt>procedure</tt> for each element in the set.
*
* @param procedure a <code>TObjectProcedure</code> value
* @return false if the loop over the set terminated because
* the procedure returned false for some value.
*/
@Override
public boolean forEach(TObjectProcedure<? super E> procedure) {
ForEachProcedure forEachProcedure = new ForEachProcedure(_set, procedure);
return order.forEach(forEachProcedure);
}
}
代码示例来源:origin: com.palantir.patches.sourceforge/trove3
/**
* Executes <tt>procedure</tt> for each element in the set.
*
* @param procedure a <code>TObjectProcedure</code> value
* @return false if the loop over the set terminated because
* the procedure returned false for some value.
*/
@Override
public boolean forEach(TObjectProcedure<? super E> procedure) {
ForEachProcedure forEachProcedure = new ForEachProcedure(_set, procedure);
return order.forEach(forEachProcedure);
}
}
代码示例来源:origin: com.conveyal/r5
transit.patternsForStop.get(stop).forEach(originalPattern -> {
int filteredPattern = index[originalPattern];
代码示例来源:origin: conveyal/r5
transit.patternsForStop.get(stop).forEach(originalPattern -> {
int filteredPattern = index[originalPattern];
代码示例来源:origin: net.sf.trove4j/trove4j
@Override
protected void writeEntries(ObjectOutput out) throws IOException {
// ENTRIES
WriteProcedure writeProcedure = new WriteProcedure(out);
if (!order.forEach(writeProcedure))
throw writeProcedure.getIoException();
}
代码示例来源:origin: com.palantir.patches.sourceforge/trove3
@Override
protected void writeEntries(ObjectOutput out) throws IOException {
// ENTRIES
WriteProcedure writeProcedure = new WriteProcedure(out);
if (!order.forEach(writeProcedure))
throw writeProcedure.getIoException();
}
代码示例来源:origin: conveyal/r5
/** Remove the permissions around a vertex for the desired mode. Returns the number of edges affected */
public void removePermissionsAroundVertex (int vertex) {
for (TIntList edgeList : new TIntList[] { streets.outgoingEdges.get(vertex), streets.incomingEdges.get(vertex) }) {
edgeList.forEach(eidx -> {
edgeCursor.seek(eidx);
switch (mode) {
case CAR:
edgeCursor.clearFlag(EdgeStore.EdgeFlag.ALLOWS_CAR);
break;
case BICYCLE:
edgeCursor.clearFlag(EdgeStore.EdgeFlag.ALLOWS_BIKE);
break;
case WALK:
edgeCursor.clearFlag(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN);
break;
default:
throw new IllegalArgumentException(String.format("Unsupported mode %s for island removal", mode));
}
return true; // continue iteration
});
}
}
}
代码示例来源:origin: com.conveyal/r5
/** Remove the permissions around a vertex for the desired mode. Returns the number of edges affected */
public void removePermissionsAroundVertex (int vertex) {
for (TIntList edgeList : new TIntList[] { streets.outgoingEdges.get(vertex), streets.incomingEdges.get(vertex) }) {
edgeList.forEach(eidx -> {
edgeCursor.seek(eidx);
switch (mode) {
case CAR:
edgeCursor.clearFlag(EdgeStore.EdgeFlag.ALLOWS_CAR);
break;
case BICYCLE:
edgeCursor.clearFlag(EdgeStore.EdgeFlag.ALLOWS_BIKE);
break;
case WALK:
edgeCursor.clearFlag(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN);
break;
default:
throw new IllegalArgumentException(String.format("Unsupported mode %s for island removal", mode));
}
return true; // continue iteration
});
}
}
}
代码示例来源:origin: com.conveyal/r5
/** Loop over every outgoing edge for a particular mode */
public void forEachOutgoingEdge (int vertex, Consumer<EdgeStore.Edge> consumer) {
streets.outgoingEdges.get(vertex).forEach(eidx -> {
edgeCursor.seek(eidx);
// filter by mode
switch (mode) {
case WALK:
if (!edgeCursor.getFlag(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN)) return true;
else break;
case CAR:
if (!edgeCursor.getFlag(EdgeStore.EdgeFlag.ALLOWS_CAR)) return true;
else break;
case BICYCLE:
// include ped mode here, because walking bikes is a thing you can do.
boolean allowsBike = edgeCursor.getFlag(EdgeStore.EdgeFlag.ALLOWS_BIKE) ||
edgeCursor.getFlag(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN);
if (!allowsBike) return true;
else break;
default:
throw new IllegalArgumentException(String.format("Unsupported mode %s for island removal", mode));
}
consumer.accept(edgeCursor);
return true; // continue iteration over outgoing edges
});
}
代码示例来源:origin: conveyal/r5
/** Loop over every outgoing edge for a particular mode */
public void forEachOutgoingEdge (int vertex, Consumer<EdgeStore.Edge> consumer) {
streets.outgoingEdges.get(vertex).forEach(eidx -> {
edgeCursor.seek(eidx);
// filter by mode
switch (mode) {
case WALK:
if (!edgeCursor.getFlag(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN)) return true;
else break;
case CAR:
if (!edgeCursor.getFlag(EdgeStore.EdgeFlag.ALLOWS_CAR)) return true;
else break;
case BICYCLE:
// include ped mode here, because walking bikes is a thing you can do.
boolean allowsBike = edgeCursor.getFlag(EdgeStore.EdgeFlag.ALLOWS_BIKE) ||
edgeCursor.getFlag(EdgeStore.EdgeFlag.ALLOWS_PEDESTRIAN);
if (!allowsBike) return true;
else break;
default:
throw new IllegalArgumentException(String.format("Unsupported mode %s for island removal", mode));
}
consumer.accept(edgeCursor);
return true; // continue iteration over outgoing edges
});
}
代码示例来源:origin: conveyal/r5
transitLayer.patternsForStop.get(stopIdx).forEach(p -> {
patternidx[0] = p;
return false;
代码示例来源:origin: com.conveyal/r5
transitLayer.patternsForStop.get(stopIdx).forEach(p -> {
patternidx[0] = p;
return false;
代码示例来源:origin: com.conveyal/r5
streetLayer.outgoingEdges.get(fromEdgeToVertex).forEach(eidx -> {
if (eidx == next[0]) {
return true;
代码示例来源:origin: com.conveyal/r5
/**
* Filter down a map from target stop indexes to distances so it only includes those stops that are the
* closest on some pattern. This is technically incorrect (think of transfers to a U shaped metro from a bus line
* running across the legs of the U, a situation which actually exists in Washington, DC with the
* red line and the Q4) but anecdotally it speeds up computation by up to 40 percent. We may want to look into
* other ways to optimize transfers (or why the transfers are making routing so much slower) if this turns out to
* affect results.
*/
private void retainClosestStopsOnPatterns(TIntIntMap timesToReachedStops) {
TIntIntMap bestStopOnPattern = new TIntIntHashMap(50, 0.5f, -1, -1);
// For every reached stop,
timesToReachedStops.forEachEntry((stopIndex, distanceToStop) -> {
// For every pattern passing through that stop,
transitLayer.patternsForStop.get(stopIndex).forEach(patternIndex -> {
int currentBestStop = bestStopOnPattern.get(patternIndex);
// Record this stop if it's the closest one yet seen on that pattern.
if (currentBestStop == -1) {
bestStopOnPattern.put(patternIndex, stopIndex);
} else {
int currentBestTime = timesToReachedStops.get(currentBestStop);
if (currentBestTime > distanceToStop) {
bestStopOnPattern.put(patternIndex, stopIndex);
}
}
return true; // iteration should continue
});
return true; // iteration should continue
});
timesToReachedStops.retainEntries((stop, distance) -> bestStopOnPattern.containsValue(stop));
}
代码示例来源:origin: conveyal/r5
/**
* Filter down a map from target stop indexes to distances so it only includes those stops that are the
* closest on some pattern. This is technically incorrect (think of transfers to a U shaped metro from a bus line
* running across the legs of the U, a situation which actually exists in Washington, DC with the
* red line and the Q4) but anecdotally it speeds up computation by up to 40 percent. We may want to look into
* other ways to optimize transfers (or why the transfers are making routing so much slower) if this turns out to
* affect results.
*/
private void retainClosestStopsOnPatterns(TIntIntMap timesToReachedStops) {
TIntIntMap bestStopOnPattern = new TIntIntHashMap(50, 0.5f, -1, -1);
// For every reached stop,
timesToReachedStops.forEachEntry((stopIndex, distanceToStop) -> {
// For every pattern passing through that stop,
transitLayer.patternsForStop.get(stopIndex).forEach(patternIndex -> {
int currentBestStop = bestStopOnPattern.get(patternIndex);
// Record this stop if it's the closest one yet seen on that pattern.
if (currentBestStop == -1) {
bestStopOnPattern.put(patternIndex, stopIndex);
} else {
int currentBestTime = timesToReachedStops.get(currentBestStop);
if (currentBestTime > distanceToStop) {
bestStopOnPattern.put(patternIndex, stopIndex);
}
}
return true; // iteration should continue
});
return true; // iteration should continue
});
timesToReachedStops.retainEntries((stop, distance) -> bestStopOnPattern.containsValue(stop));
}
内容来源于网络,如有侵权,请联系作者删除!