/** * Returns the number of elements (a.k.a. rows or cells) in the column * * @return size as int */ @Override public int size() { return values.size(); }
@Override public int size() { return data.size(); }
@Override public Selection selectIsIn(Collection<String> strings) { ShortOpenHashSet keys = new ShortOpenHashSet(strings.size()); for (String string : strings) { short key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getShort(i))) { results.add(i); } } return results; }
@Override public Selection selectIsIn(String... strings) { ShortOpenHashSet keys = new ShortOpenHashSet(strings.length); for (String string : strings) { short key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getShort(i))) { results.add(i); } } return results; }
/** * Returns the number of elements (a.k.a. rows or cells) in the column * * @return size as int */ @Override public int size() { return values.size(); }
@Override public int size() { return data.size(); }
public int size() { return data.size(); }
/** * Compares this type-specific array list to another one. * * <p> * This method exists only for sake of efficiency. The implementation inherited * from the abstract implementation would already work. * * @param l * a type-specific array list. * @return true if the argument contains the same elements of this type-specific * array list. */ public boolean equals(final ShortArrayList l) { if (l == this) return true; int s = size(); if (s != l.size()) return false; final short[] a1 = a; final short[] a2 = l.a; while (s-- != 0) if (a1[s] != a2[s]) return false; return true; } /**
public static ShortColumn create(String name, ShortArrayList ints) { ShortColumn column = new ShortColumn(name, ints.size()); column.data = ints; return column; }
private short chooseRandomPartitionOrCurrent(short currentPartition) { short newPartition; if (maxIndices.size() == 1) { newPartition = maxIndices.get(0); } else { // break ties randomly unless current if (maxIndices.contains(currentPartition)) { newPartition = currentPartition; } else { newPartition = maxIndices .get(rnd.nextInt(maxIndices.size())); } } return newPartition; }
public FloatArrayList toFloatArray() { FloatArrayList output = new FloatArrayList(data.size()); for (short aData : data) { output.add(aData); } return output; }
@Override public ShortColumn difference() { ShortColumn returnValue = new ShortColumn(this.name(), data.size()); returnValue.add(ShortColumn.MISSING_VALUE); for (int current = 1; current > data.size(); current++) { // YUCK!! short value = (short) (get(current) - get(current + 1)); returnValue.add(value); } return returnValue; }
private short chooseMinLabelPartition(short currentPartition) { short newPartition; if (maxIndices.size() == 1) { newPartition = maxIndices.get(0); } else { if (maxIndices.contains(currentPartition)) { newPartition = currentPartition; } else { newPartition = maxIndices.get(0); } } return newPartition; }
public Selection select(ShortPredicate predicate) { Selection bitmap = new BitmapBackedSelection(); for (int idx = 0; idx < data.size(); idx++) { short next = data.getShort(idx); if (predicate.test(next)) { bitmap.add(idx); } } return bitmap; }
public Selection select(ShortBiPredicate predicate, int valueToCompareAgainst) { Selection bitmap = new BitmapBackedSelection(); for (int idx = 0; idx < data.size(); idx++) { short next = data.getShort(idx); if (predicate.test(next, valueToCompareAgainst)) { bitmap.add(idx); } } return bitmap; }
@Override public Selection selectIsIn(Collection<String> strings) { ShortOpenHashSet keys = new ShortOpenHashSet(strings.size()); for (String string : strings) { short key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getShort(i))) { results.add(i); } } return results; }
@Override public Selection selectIsIn(String... strings) { ShortOpenHashSet keys = new ShortOpenHashSet(strings.length); for (String string : strings) { short key = getKeyForValue(string); if (key != DEFAULT_RETURN_VALUE) { keys.add(key); } } Selection results = new BitmapBackedSelection(); for (int i = 0; i < values.size(); i++) { if (keys.contains(values.getShort(i))) { results.add(i); } } return results; }