public void clear() { for (ObjectArrayList<Block> channel : channels) { channel.clear(); channel.trim(); } valueAddresses.clear(); valueAddresses.trim(); positionCount = 0; nextBlockToCompact = 0; pagesMemorySize = 0; estimatedSize = calculateEstimatedSize(); }
/** * Returns a new LongColumn containing a value for each value in this column * * A widening primitive conversion from short to long does not lose any information at all; * the numeric value is preserved exactly. * * A missing value in the receiver is converted to a missing value in the result */ @Override public LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (int f : data) { values.add(f); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
/** * Returns a new LongColumn containing a value for each value in this column * * A widening primitive conversion from int to long does not lose any information at all; * the numeric value is preserved exactly. * * A missing value in the receiver is converted to a missing value in the result */ @Override public LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (int f : data) { values.add(f); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
/** * Returns a new LongColumn containing a value for each value in this column, truncating if necessary * * A narrowing primitive conversion such as this one may lose information about the overall magnitude of a * numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value * of large magnitude or negative infinity), the result is the smallest representable value of type long. * * Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the * largest representable value of type long. * * Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive * conversion never results in a run-time exception. * * A missing value in the receiver is converted to a missing value in the result */ @Override public LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (double d : data) { values.add((long) d); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
/** * Returns a new LongColumn containing a value for each value in this column, truncating if necessary * * A narrowing primitive conversion such as this one may lose information about the overall magnitude of a * numeric value and may also lose precision and range. Specifically, if the value is too small (a negative value * of large magnitude or negative infinity), the result is the smallest representable value of type long. * * Similarly, if the value is too large (a positive value of large magnitude or positive infinity), the result is the * largest representable value of type long. * * Despite the fact that overflow, underflow, or other loss of information may occur, a narrowing primitive * conversion never results in a run-time exception. * * A missing value in the receiver is converted to a missing value in the result */ @Override public LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (float f : data) { values.add((long) f); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
/** * Trims this array list so that the capacity is equal to the size. * * @see java.util.ArrayList#trimToSize() */ public void trim() { trim(0); } /**
@Override public void trim() { neighbors.trim(); } }
private static Long2DoubleMap extractVector(Iterator<? extends Rating> ratings, IdExtractor dimension, int n) { LongArrayList ids = new LongArrayList(n > 0 ? n : LongArrayList.DEFAULT_INITIAL_CAPACITY); DoubleArrayList values = new DoubleArrayList(n > 0 ? n : DoubleArrayList.DEFAULT_INITIAL_CAPACITY); while (ratings.hasNext()) { Rating r = ratings.next(); assert ids.size() == values.size(); long id = dimension.getId(r); ids.add(id); values.add(r.getValue()); } ids.trim(); values.trim(); assert ids.elements().length == ids.size(); assert values.elements().length == values.size(); return Long2DoubleSortedArrayMap.wrapUnsorted(ids.elements(), values.elements()); }
public void trim() { if (fullImpl != null) { boolean compactable = true; for (LongIterator iter = fullImpl.iterator(); compactable && iter.hasNext();) { final long value = iter.nextLong(); if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) { compactable = false; } } if (compactable) { compactImpl = new IntArrayList(fullImpl.size()); for (LongIterator iter = fullImpl.iterator(); iter.hasNext();) { final long value = iter.nextLong(); compactImpl.add((int) value); } fullImpl = null; } else { fullImpl.trim(); } } else { assert compactImpl != null; compactImpl.trim(); } }
@Override public void trim() { neighbors.trim(); edgeValues.trim(); } }
@Override public void seal() { ((LongArrayList) _innerList).trim(); _elements = ((LongArrayList) _innerList).elements(); }
@Override public void seal() { ((LongArrayList) _innerList).trim(); _elements = ((LongArrayList) _innerList).elements(); int negativeIndexCheck = withDummy ? 1 : 0; // reverse negative elements, because string order and numeric orders are completely opposite if (_elements.length > negativeIndexCheck && _elements[negativeIndexCheck] < 0) { int endPosition = indexOfWithType(0L); if (endPosition < 0) { endPosition = -1 * endPosition - 1; } long tmp; for (int i = 0; i < (endPosition - negativeIndexCheck) / 2; i++) { tmp = _elements[i + negativeIndexCheck]; _elements[i + negativeIndexCheck] = _elements[endPosition - i - 1]; _elements[endPosition - i - 1] = tmp; } } }
/** * Pours an iterator, returning a type-specific list, with a limit on the number * of elements. * * <p> * This method iterates over the given type-specific iterator and returns a * type-specific list containing the returned elements (up to {@code max}). * Iteration on the returned list is guaranteed to produce the elements in the * same order in which they appeared in the iterator. * * * @param i * a type-specific iterator. * @param max * the maximum number of elements to be poured. * @return a type-specific list containing the returned elements, up to * {@code max}. */ public static LongList pour(final LongIterator i, int max) { final LongArrayList l = new LongArrayList(); pour(i, l, max); l.trim(); return l; } /**
/** * If the backing array is more than four times as big as the number of * elements, halve its size. */ private void trimBack() { if (neighbors.elements().length > 4 * neighbors.size()) { neighbors.trim(neighbors.elements().length / 2); } }
public void clear() { for (ObjectArrayList<Block> channel : channels) { channel.clear(); channel.trim(); } valueAddresses.clear(); valueAddresses.trim(); positionCount = 0; nextBlockToCompact = 0; pagesMemorySize = 0; estimatedSize = calculateEstimatedSize(); }
public void clear() { for (ObjectArrayList<Block> channel : channels) { channel.clear(); channel.trim(); } valueAddresses.clear(); valueAddresses.trim(); positionCount = 0; nextBlockToCompact = 0; pagesMemorySize = 0; estimatedSize = calculateEstimatedSize(); }
/** * If the backing arrays are more than four times as big as the number of * elements, halve their size. */ private void trimBack() { if (neighbors.elements().length > 4 * neighbors.size()) { neighbors.trim(neighbors.elements().length / 2); edgeValues.trim(neighbors.elements().length / 2); } }
/** * Returns a new LongColumn containing a value for each value in this column * * A widening primitive conversion from int to long does not lose any information at all; * the numeric value is preserved exactly. * * A missing value in the receiver is converted to a missing value in the result */ @Override public LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (int f : data) { values.add(f); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
/** * Returns a new LongColumn containing a value for each value in this column * * A widening primitive conversion from short to long does not lose any information at all; * the numeric value is preserved exactly. * * A missing value in the receiver is converted to a missing value in the result */ @Override public LongColumn asLongColumn() { LongArrayList values = new LongArrayList(); for (int f : data) { values.add(f); } values.trim(); return LongColumn.create(this.name(), values.elements()); }
private static Long2DoubleMap extractVector(Iterator<? extends Rating> ratings, IdExtractor dimension, int n) { LongArrayList ids = new LongArrayList(n > 0 ? n : LongArrayList.DEFAULT_INITIAL_CAPACITY); DoubleArrayList values = new DoubleArrayList(n > 0 ? n : DoubleArrayList.DEFAULT_INITIAL_CAPACITY); while (ratings.hasNext()) { Rating r = ratings.next(); assert ids.size() == values.size(); long id = dimension.getId(r); ids.add(id); values.add(r.getValue()); } ids.trim(); values.trim(); assert ids.elements().length == ids.size(); assert values.elements().length == values.size(); return Long2DoubleSortedArrayMap.wrapUnsorted(ids.elements(), values.elements()); }