public static ShortColumn create(final String name) { return new ShortColumn(name, new ShortArrayList()); }
public static ShortColumn create(final String name, final short[] arr) { return new ShortColumn(name, new ShortArrayList(arr)); }
public static ShortColumn create(final String name, final int initialSize) { ShortColumn column = new ShortColumn(name, new ShortArrayList(initialSize)); for (int i = 0; i < initialSize; i++) { column.appendMissing(); } return column; }
@Override public void sortDescending() { short[] elements = values.toShortArray(); ShortArrays.parallelQuickSort(elements, reverseDictionarySortComparator); this.values = new ShortArrayList(elements); }
@Override public void sortAscending() { short[] elements = values.toShortArray(); ShortArrays.parallelQuickSort(elements, dictionarySortComparator); this.values = new ShortArrayList(elements); }
@Override public ShortColumn lag(int n) { final int srcPos = n >= 0 ? 0 : 0 - n; final short[] dest = new short[size()]; final int destPos = n <= 0 ? 0 : n; final int length = n >= 0 ? size() - n : size() + n; for (int i = 0; i < size(); i++) { dest[i] = ShortColumnType.missingValueIndicator(); } short[] array = data.toShortArray(); System.arraycopy(array, srcPos, dest, destPos, length); return new ShortColumn(name() + " lag(" + n + ")", new ShortArrayList(dest)); }
@Override public ShortColumn bottom(final int n) { final ShortArrayList bottom = new ShortArrayList(); final short[] values = data.toShortArray(); ShortArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new ShortColumn(name() + "[Bottoms " + n + "]", bottom); }
@Override public ShortColumn top(int n) { final ShortArrayList top = new ShortArrayList(); final short[] values = data.toShortArray(); ShortArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new ShortColumn(name() + "[Top " + n + "]", top); }
/** * Returns a new IntColumn 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 int. * * 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 int. * * 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 ShortColumn asShortColumn() { ShortArrayList values = new ShortArrayList(); for (float d : data) { values.add((short) d); } values.trim(); return ShortColumn.create(this.name(), values.elements()); }
/** * Returns a new ShortColumn containing a value for each value in this column * * A narrowing conversion of a signed long to an integral type T simply discards all but the n lowest order bits, * where n is the number of bits used to represent type T. In addition to a possible loss of information about * the magnitude of the numeric value, this may cause the sign of the resulting value to differ from the sign of * the input value. * * In other words, if the element being converted is larger (or smaller) than Short.MAX_VALUE * (or Short.MIN_VALUE) you will not get a conventionally good conversion. * * 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 ShortColumn asShortColumn() { ShortArrayList values = new ShortArrayList(); for (long f : data) { values.add((short) f); } values.trim(); return ShortColumn.create(this.name(), values.elements()); }
/** * Returns a new ShortColumn containing a value for each value in this column * * A narrowing conversion of a signed integer to an integral type T simply discards all but the n lowest order bits, * where n is the number of bits used to represent type T. In addition to a possible loss of information about * the magnitude of the numeric value, this may cause the sign of the resulting value to differ from the sign of * the input value. * * In other words, if the element being converted is larger (or smaller) than Short.MAX_VALUE * (or Short.MIN_VALUE) you will not get a conventionally good conversion. * * 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 ShortColumn asShortColumn() { ShortArrayList values = new ShortArrayList(); for (int f : data) { values.add((short) f); } values.trim(); return ShortColumn.create(this.name(), values.elements()); }
/** * Returns a new ShortColumn 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 int. * * 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 short. * * 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 ShortColumn asShortColumn() { ShortArrayList values = new ShortArrayList(); for (double d : data) { values.add((short) d); } values.trim(); return ShortColumn.create(this.name(), values.elements()); }
@Override protected List<?> buildPrimitiveList(int capacity) { _type = Short.class; return capacity > 0 ? new ShortArrayList(capacity) : new ShortArrayList(); }
public ShortColumn(String name, int initialSize) { super(name); data = new ShortArrayList(initialSize); }
@Override public ShortArrayList clone() { ShortArrayList c = new ShortArrayList(size); System.arraycopy(a, 0, c.a, 0, size); c.size = size; return c; } /**
public static ShortColumn create(final String name, final int initialSize) { ShortColumn column = new ShortColumn(name, new ShortArrayList(initialSize)); for (int i = 0; i < initialSize; i++) { column.appendMissing(); } return column; }
@Override public void sortAscending() { short[] elements = values.toShortArray(); ShortArrays.parallelQuickSort(elements, dictionarySortComparator); this.values = new ShortArrayList(elements); }
@Override public void sortDescending() { short[] elements = values.toShortArray(); ShortArrays.parallelQuickSort(elements, reverseDictionarySortComparator); this.values = new ShortArrayList(elements); }
@Override public ShortColumn top(int n) { final ShortArrayList top = new ShortArrayList(); final short[] values = data.toShortArray(); ShortArrays.parallelQuickSort(values, descendingComparator); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return new ShortColumn(name() + "[Top " + n + "]", top); }
@Override public ShortColumn bottom(final int n) { final ShortArrayList bottom = new ShortArrayList(); final short[] values = data.toShortArray(); ShortArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return new ShortColumn(name() + "[Bottoms " + n + "]", bottom); }