public float[] getFloatRow(int row) { float[] outgoing = new float[columns.length]; for (int col = 0; col < columns.length; col++) { outgoing[col] = getFloat(row, col); } return outgoing; }
public float[] getFloatRow(int row) { float[] outgoing = new float[columns.length]; for (int col = 0; col < columns.length; col++) { outgoing[col] = getFloat(row, col); } return outgoing; }
public float[] getFloatColumn(int col) { float[] outgoing = new float[rowCount]; for (int row = 0; row < rowCount; row++) { outgoing[row] = getFloat(row, col); } return outgoing; }
public float[] getFloatColumn(int col) { float[] outgoing = new float[rowCount]; for (int row = 0; row < rowCount; row++) { outgoing[row] = getFloat(row, col); } return outgoing; }
public float getFloat(int column) { return table.getFloat(row, column); }
public float getFloat(String columnName) { return table.getFloat(row, columnName); }
public float getFloat(int column) { return table.getFloat(row, column); }
public float getFloat(String columnName) { return table.getFloat(row, columnName); }
/** * @param columnName title of the column to reference */ public float getFloat(int row, String columnName) { return getFloat(row, getColumnIndex(columnName)); }
/** * @param columnName title of the column to reference */ public float getFloat(int row, String columnName) { return getFloat(row, getColumnIndex(columnName)); }
/** * Searches the entire table for float values. * Returns missing float (Float.NaN by default) if no valid numbers found. */ protected float getMaxFloat() { boolean found = false; float max = PConstants.MIN_FLOAT; for (int row = 0; row < getRowCount(); row++) { for (int col = 0; col < getColumnCount(); col++) { float value = getFloat(row, col); if (!Float.isNaN(value)) { // TODO no, this should be comparing to the missing value if (!found) { max = value; found = true; } else if (value > max) { max = value; } } } } return found ? max : missingFloat; }
/** * Searches the entire table for float values. * Returns missing float (Float.NaN by default) if no valid numbers found. */ protected float getMaxFloat() { boolean found = false; float max = PConstants.MIN_FLOAT; for (int row = 0; row < getRowCount(); row++) { for (int col = 0; col < getColumnCount(); col++) { float value = getFloat(row, col); if (!Float.isNaN(value)) { // TODO no, this should be comparing to the missing value if (!found) { max = value; found = true; } else if (value > max) { max = value; } } } } return found ? max : missingFloat; }
@Override public float compare(int index1, int index2) { int a = reverse ? order[index2] : order[index1]; int b = reverse ? order[index1] : order[index2]; switch (getColumnType(column)) { case INT: return getInt(a, column) - getInt(b, column); case LONG: return getLong(a, column) - getLong(b, column); case FLOAT: return getFloat(a, column) - getFloat(b, column); case DOUBLE: return (float) (getDouble(a, column) - getDouble(b, column)); case STRING: return getString(a, column).compareToIgnoreCase(getString(b, column)); case CATEGORY: return getInt(a, column) - getInt(b, column); default: throw new IllegalArgumentException("Invalid column type: " + getColumnType(column)); } }
@Override public float compare(int index1, int index2) { int a = reverse ? order[index2] : order[index1]; int b = reverse ? order[index1] : order[index2]; switch (getColumnType(column)) { case INT: return getInt(a, column) - getInt(b, column); case LONG: return getLong(a, column) - getLong(b, column); case FLOAT: return getFloat(a, column) - getFloat(b, column); case DOUBLE: return (float) (getDouble(a, column) - getDouble(b, column)); case STRING: return getString(a, column).compareToIgnoreCase(getString(b, column)); case CATEGORY: return getInt(a, column) - getInt(b, column); default: throw new IllegalArgumentException("Invalid column type: " + getColumnType(column)); } }
protected Table createSubset(int[] rowSubset) { Table newbie = new Table(); newbie.setColumnTitles(columnTitles); // also sets columns.length newbie.columnTypes = columnTypes; newbie.setRowCount(rowSubset.length); for (int i = 0; i < rowSubset.length; i++) { int row = rowSubset[i]; for (int col = 0; col < columns.length; col++) { switch (columnTypes[col]) { case STRING: newbie.setString(i, col, getString(row, col)); break; case INT: newbie.setInt(i, col, getInt(row, col)); break; case LONG: newbie.setLong(i, col, getLong(row, col)); break; case FLOAT: newbie.setFloat(i, col, getFloat(row, col)); break; case DOUBLE: newbie.setDouble(i, col, getDouble(row, col)); break; } } } return newbie; }
protected Table createSubset(int[] rowSubset) { Table newbie = new Table(); newbie.setColumnTitles(columnTitles); // also sets columns.length newbie.columnTypes = columnTypes; newbie.setRowCount(rowSubset.length); for (int i = 0; i < rowSubset.length; i++) { int row = rowSubset[i]; for (int col = 0; col < columns.length; col++) { switch (columnTypes[col]) { case STRING: newbie.setString(i, col, getString(row, col)); break; case INT: newbie.setInt(i, col, getInt(row, col)); break; case LONG: newbie.setLong(i, col, getLong(row, col)); break; case FLOAT: newbie.setFloat(i, col, getFloat(row, col)); break; case DOUBLE: newbie.setDouble(i, col, getDouble(row, col)); break; } } } return newbie; }