public ShortColumn append(short i) { data.add(i); return this; }
@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 void append(String value) throws NoKeysAvailableException { short key; if (value == null || StringColumnType.missingValueIndicator().equals(value)) { key = MISSING_VALUE; put(key, StringColumnType.missingValueIndicator()); } else { key = getKeyForValue(value); } if (key == DEFAULT_RETURN_VALUE) { key = getValueId(); put(key, value); } values.add(key); }
@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 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 * * 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, 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 public void add(short k) { ShortArrayList.this.add(pos++, k); last = -1; } @Override
@Override public void addShort(short value) { list.add(value); } };
public ShortColumn append(short i) { data.add(i); return this; }
public void add(short i) { data.add(i); }
/** * Creates a new array list and fills it with the elements returned by an * iterator.. * * @param i * an iterator whose returned elements will fill the array list. */ public ShortArrayList(final Iterator<? extends Short> i) { this(); while (i.hasNext()) this.add((i.next()).shortValue()); } /**
@Override public boolean add(String o) { if (_innerList.size() == 0 && o != null) withDummy = false; // the first value added is not null short item = parse(o); return ((ShortArrayList) _innerList).add(item); }
/** * Creates a new array list and fills it with the elements returned by a * type-specific iterator.. * * @param i * a type-specific iterator whose returned elements will fill the * array list. */ public ShortArrayList(final ShortIterator i) { this(); while (i.hasNext()) this.add(i.nextShort()); } /**
/** * Returns the smallest ("bottom") n values in the column * * @param n The maximum number of records to return. The actual number will be smaller if n is greater than the * number of observations in the column * @return A list, possibly empty, of the smallest n observations */ public ShortArrayList bottom(int n) { ShortArrayList bottom = new ShortArrayList(); short[] values = data.toShortArray(); ShortArrays.parallelQuickSort(values); for (int i = 0; i < n && i < values.length; i++) { bottom.add(values[i]); } return bottom; }
/** * Returns the largest ("top") n values in the column * * @param n The maximum number of records to return. The actual number will be smaller if n is greater than the * number of observations in the column * @return A list, possibly empty, of the largest observations */ public ShortArrayList top(int n) { ShortArrayList top = new ShortArrayList(); short[] values = data.toShortArray(); ShortArrays.parallelQuickSort(values, ReverseShortComparator.instance()); for (int i = 0; i < n && i < values.length; i++) { top.add(values[i]); } return top; }
@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); }
@Override public void append(String value) throws NoKeysAvailableException { short key; if (value == null || StringColumnType.missingValueIndicator().equals(value)) { key = MISSING_VALUE; put(key, StringColumnType.missingValueIndicator()); } else { key = getKeyForValue(value); } if (key == DEFAULT_RETURN_VALUE) { key = getValueId(); put(key, value); } values.add(key); }