public TObjectHashIterator<E> iterator() { return new TObjectHashIterator<E>(this) { TIntIterator localIterator = order.iterator(); int lastIndex;
public TIntLinkedList(TIntList list) { no_entry_value = list.getNoEntryValue(); // for (TIntIterator iterator = list.iterator(); iterator.hasNext();) { int next = iterator.next(); add(next); } }
/** * Calculates Stats for the transfer to the given ride from the previous ride. * This should only be called after all PatternRides have been added to the ride. * Distances can be stored in rides, including the first and last distance. But waits must be * calculated from full sets of patterns, which are not known until a round is over. */ public Stats calcStatsForTransfer (TimeWindow window, double walkSpeed) { TIntList arrivals = previous.getSortedStoptimes(window, true); TIntList departures = this.getSortedStoptimes(window, false); List<Integer> waits = Lists.newArrayList(); TIntIterator departureIterator = departures.iterator(); int departure = departureIterator.next(); ARRIVAL : for (TIntIterator arrivalsIterator = arrivals.iterator(); arrivalsIterator.hasNext();) { int arrival = arrivalsIterator.next(); // On transfers the access stats should have max=min=avg // We use the min, which would be best if min != max since it should only relax the bounds somewhat. int boardTime = arrival + accessStats.min + ProfileRouter.SLACK; while (departure <= boardTime) { if (!departureIterator.hasNext()) break ARRIVAL; departure = departureIterator.next(); } waits.add(departure - boardTime); } /* Waits list may be empty if no transfers are possible. */ if (waits.isEmpty()) return null; // Impossible to make this transfer. return new Stats (waits); }
private int calculateTotal(int base, TFloatList multipliers, TIntList modifiers) { // For now, add all modifiers and multiply by all multipliers. Negative modifiers cap to zero, but negative // multipliers remain (so damage can be flipped to healing) float total = base; TIntIterator modifierIter = modifiers.iterator(); while (modifierIter.hasNext()) { total += modifierIter.next(); } total = Math.max(0, total); if (total == 0) { return 0; } TFloatIterator multiplierIter = multipliers.iterator(); while (multiplierIter.hasNext()) { total *= multiplierIter.next(); } return TeraMath.floorToInt(total); }
/** * Produce stats about boarding an initial Ride, which has no previous ride. * This assumes arrival times are uniformly distributed during the window. * The Ride must contain some trips, and the window must have a positive duration. */ public Stats calcStatsForBoarding(TimeWindow window) { Stats stats = new Stats (); stats.min = 0; // You can always arrive just before a train departs. TIntList departures = getSortedStoptimes(window, false); int last = window.from; double avgAccumulated = 0.0; /* All departures in the list are known to be running and within the window. */ for (TIntIterator it = departures.iterator(); it.hasNext();) { int dep = it.next(); int maxWait = dep - last; if (maxWait > stats.max) stats.max = maxWait; /* Weight the average of each interval by the number of seconds it contains. */ avgAccumulated += (maxWait / 2.0) * maxWait; stats.num += maxWait; last = dep; } if (stats.num > 0) { stats.avg = (int) (avgAccumulated / stats.num); } return stats; }
TIntIterator indexIterator = elements.indices.iterator(); while (indexIterator.hasNext()) { elements.finalIndices.put(indexIterator.next());
private void createIndexBuffer(TIntList indexList) { IntBuffer indexBuffer = BufferUtils.createIntBuffer(indexList.size()); TIntIterator iterator = indexList.iterator(); while (iterator.hasNext()) { indexBuffer.put(iterator.next()); } indexBuffer.flip(); if (disposalAction.vboIndexBuffer == 0) { disposalAction.vboIndexBuffer = disposalAction.bufferPool.get(getUrn().toString()); } VertexBufferObjectUtil.bufferVboElementData(disposalAction.vboIndexBuffer, indexBuffer, GL15.GL_STATIC_DRAW); indexBuffer.flip(); }
for (TIntIterator it = stopForIndex.iterator(); it.hasNext();) { int stop = it.next(); TIntList transfers = new TIntArrayList(); for (TIntIterator stopIt = stopForIndex.iterator(); stopIt.hasNext();) { int stop = stopIt.next(); for (TIntIterator stopIt = stopForIndex.iterator(); stopIt.hasNext();) { out.clear();
/** * Compute the centroid for each class. * * @param dim Dimensionality * @param vectorcolumn Vector column * @param keys Key index * @param classes Classes * @return Centroids for each class. */ protected List<Centroid> computeCentroids(int dim, List<V> vectorcolumn, List<ClassLabel> keys, Map<ClassLabel, TIntList> classes) { final int numc = keys.size(); List<Centroid> centroids = new ArrayList<>(numc); for (int i = 0; i < numc; i++) { Centroid c = new Centroid(dim); // Note: GNU Trove iterator, not ELKI style! for (TIntIterator it = classes.get(keys.get(i)).iterator(); it.hasNext();) { c.put(vectorcolumn.get(it.next())); } centroids.add(c); } return centroids; }
/** * Replaces the current buffer data with the list of bytes in the give {@link gnu.trove.list.TIntList} This method arbitrarily creates data for the ByteBuffer regardless of the data type of the * vertex attribute. * * @param list to set */ public void setData(TIntList list) { this.buffer = CausticUtil.createByteBuffer(list.size() * DataType.INT.getByteSize()); final TIntIterator iterator = list.iterator(); while (iterator.hasNext()) { buffer.putInt(iterator.next()); } }
public TIntLinkedList(TIntList list) { no_entry_value = list.getNoEntryValue(); // for (TIntIterator iterator = list.iterator(); iterator.hasNext();) { int next = iterator.next(); add(next); } }
public TIntLinkedList(TIntList list) { no_entry_value = list.getNoEntryValue(); // for (TIntIterator iterator = list.iterator(); iterator.hasNext();) { int next = iterator.next(); add(next); } }
/** * Get a single best state at a vertex. NB this should not be used for propagating to samples, as you need to apply * turn costs/restrictions during propagation. */ public State getStateAtVertex (int vertexIndex) { State ret = null; TIntList edgeList; if (profileRequest.reverseSearch) { edgeList = streetLayer.outgoingEdges.get(vertexIndex); } else { edgeList = streetLayer.incomingEdges.get(vertexIndex); } for (TIntIterator it = edgeList.iterator(); it.hasNext();) { int eidx = it.next(); State state = getStateAtEdge(eidx); if (state == null) continue; if (ret == null) ret = state; else if (ret.getRoutingVariable(quantityToMinimize) > state.getRoutingVariable(quantityToMinimize)) { ret = state; } } return ret; }
/** * Get a single best state at a vertex. NB this should not be used for propagating to samples, as you need to apply * turn costs/restrictions during propagation. */ public State getStateAtVertex (int vertexIndex) { State ret = null; TIntList edgeList; if (profileRequest.reverseSearch) { edgeList = streetLayer.outgoingEdges.get(vertexIndex); } else { edgeList = streetLayer.incomingEdges.get(vertexIndex); } for (TIntIterator it = edgeList.iterator(); it.hasNext();) { int eidx = it.next(); State state = getStateAtEdge(eidx); if (state == null) continue; if (ret == null) ret = state; else if (ret.getRoutingVariable(quantityToMinimize) > state.getRoutingVariable(quantityToMinimize)) { ret = state; } } return ret; }
/** * Returns true if any of the on bit indexes of the specified collection are * matched by the on bits of this matrix. It is allowed that * this matrix have more on bits than the specified matrix. * * @param matrix * @return */ public boolean any(TIntList onBits) { TIntSet keySet = getSparseSet(); for(TIntIterator i = onBits.iterator();i.hasNext();) { if(keySet.contains(i.next())) return true; } return false; }
for (TIntIterator patternIt = patterns.iterator(); patternIt.hasNext();) { int pattern = patternIt.next();
for (TIntIterator patternIt = patterns.iterator(); patternIt.hasNext();) { int pattern = patternIt.next();
private void processDenseChangedEvt(VectorSet evtSrc, int vecid, float[] vector) { if (evtSrc == this.source) { target.rescore(source.key(), vecid, vector, this); } else if (evtSrc == this.target) { int tgtVecId = vecid; TIntIterator iter = sorterKeys.iterator(); while (iter.hasNext()) { int srcVecId = iter.next(); float score = scoring.score(source.key(), srcVecId, source.get(srcVecId), target.key(), tgtVecId, vector); add(srcVecId, tgtVecId, score); } } }
private void processSparseChangedEvt(VectorSet evtSrc, int vecid, int[] vector) { if (evtSrc == this.source) { target.rescore(source.key(), vecid, vector, this); } else if (evtSrc == this.target) { int tgtVecId = vecid; TIntIterator iter = sorterKeys.iterator(); while (iter.hasNext()) { int srcVecId = iter.next(); float score = scoring.score(source.key(), srcVecId, source._get(srcVecId), source.length(srcVecId), target.key(), tgtVecId, vector, vector.length); add(srcVecId, tgtVecId, score); } } }
reverseIndexer = new TIntObjectHashMap<TIntSet>(); TIntIterator iter = oldSorterKeys.iterator(); while (iter.hasNext()) { int srcId = iter.next();