/** * Returns the {@link DataSpec} instances passed to {@link #open(DataSpec)} since the last call to * this method. */ public final DataSpec[] getAndClearOpenedDataSpecs() { DataSpec[] dataSpecs = new DataSpec[openedDataSpecs.size()]; openedDataSpecs.toArray(dataSpecs); openedDataSpecs.clear(); return dataSpecs; }
private int[][][][] createPartialDataForLOP(int lopIter, int[][][][] data) { ArrayList<Integer> newFeatureList = new ArrayList<>(1000); Set<Integer> featureIndicesSet = featureIndicesSetArray.get(lopIter); int[][][][] newData = new int[data.length][][][]; for (int i = 0; i < data.length; i++) { newData[i] = new int[data[i].length][][]; for (int j = 0; j < data[i].length; j++) { newData[i][j] = new int[data[i][j].length][]; for (int k = 0; k < data[i][j].length; k++) { int[] oldFeatures = data[i][j][k]; newFeatureList.clear(); for (int oldFeatureIndex : oldFeatures) { if (featureIndicesSet.contains(oldFeatureIndex)) { newFeatureList.add(oldFeatureIndex); } } newData[i][j][k] = new int[newFeatureList.size()]; for (int l = 0; l < newFeatureList.size(); ++l) { newData[i][j][k][l] = newFeatureList.get(l); } } } } return newData; }
private void cancelAllChores(final boolean mayInterruptIfRunning) { ArrayList<ScheduledChore> choresToCancel = new ArrayList<>(scheduledChores.keySet().size()); // Build list of chores to cancel so we can iterate through a set that won't change // as chores are cancelled. If we tried to cancel each chore while iterating through // keySet the results would be undefined because the keySet would be changing for (ScheduledChore chore : scheduledChores.keySet()) { choresToCancel.add(chore); } for (ScheduledChore chore : choresToCancel) { cancelChore(chore, mayInterruptIfRunning); } choresToCancel.clear(); }
private void applyOffset() { if (offset <= 0) { return; } if (external == null) { if (offset >= rows.size()) { rows.clear(); rowCount = 0; } else { // avoid copying the whole array for each row int remove = Math.min(offset, rows.size()); rows = new ArrayList<>(rows.subList(remove, rows.size())); rowCount -= remove; } } else { if (offset >= rowCount) { rowCount = 0; } else { diskOffset = offset; rowCount -= offset; } } distinctRows = null; }
public void setInitalPositionMultiPoints(MotionEvent event) { touchPoints.clear(); int pointerIndex = 0; for (int index = 0; index < event.getPointerCount(); ++index) { pointerIndex = event.getPointerId(index); touchPoints.add(new PointF(event.getX(pointerIndex), event.getY(pointerIndex))); } double r = Math.atan2(touchPoints.get(1).x - touchPoints.get(1 - 1).x, touchPoints.get(1).y - touchPoints.get(1 - 1).y); old_degrees = -(int) Math.toDegrees(r); }
@Override public synchronized Optional<CompactionContext> selectCompaction() { CompactionContext ctx = new TestCompactionContext(new ArrayList<>(notCompacting)); compacting.addAll(notCompacting); notCompacting.clear(); try { ctx.select(null, false, false, false); } catch (IOException ex) { fail("Shouldn't happen"); } return Optional.of(ctx); }
@Override public void reduce(Iterable<Tuple2<Long, Long>> values, Collector<Tuple2<Long, Long[]>> out) { neighbors.clear(); Long id = 0L; for (Tuple2<Long, Long> n : values) { id = n.f0; neighbors.add(n.f1); } out.collect(new Tuple2<Long, Long[]>(id, neighbors.toArray(new Long[neighbors.size()]))); } }
public ArrayList<MenuItem> getVisibleItems() { if (!mIsVisibleItemsStale) return mVisibleItems; // Refresh the visible items mVisibleItems.clear(); final int itemsSize = mItems.size(); MenuItem item; for (int i = 0; i < itemsSize; i++) { item = mItems.get(i); if (item.isVisible()) mVisibleItems.add(item); } mIsVisibleItemsStale = false; return mVisibleItems; }
public GradientPanel (GradientColorValue value, String name, String description, boolean hideGradientEditor) { super(value, name, description); this.value = value; initializeComponents(); if (hideGradientEditor) { gradientEditor.setVisible(false); } gradientEditor.percentages.clear(); for (float percent : value.getTimeline()) gradientEditor.percentages.add(percent); gradientEditor.colors.clear(); float[] colors = value.getColors(); for (int i = 0; i < colors.length;) { float r = colors[i++]; float g = colors[i++]; float b = colors[i++]; gradientEditor.colors.add(new Color(r, g, b)); } if (gradientEditor.colors.isEmpty() || gradientEditor.percentages.isEmpty()) { gradientEditor.percentages.clear(); gradientEditor.percentages.add(0f); gradientEditor.percentages.add(1f); gradientEditor.colors.clear(); gradientEditor.colors.add(Color.white); } setColor(gradientEditor.colors.get(0)); }
/** * Reads WALEdit from cells. * @param cellDecoder Cell decoder. * @param expectedCount Expected cell count. * @return Number of KVs read. */ public int readFromCells(Codec.Decoder cellDecoder, int expectedCount) throws IOException { cells.clear(); cells.ensureCapacity(expectedCount); while (cells.size() < expectedCount && cellDecoder.advance()) { cells.add(cellDecoder.current()); } return cells.size(); }