public int[] getIntRow(int row) { int[] outgoing = new int[columns.length]; for (int col = 0; col < columns.length; col++) { outgoing[col] = getInt(row, col); } return outgoing; }
public int[] getIntColumn(int col) { int[] outgoing = new int[rowCount]; for (int row = 0; row < rowCount; row++) { outgoing[row] = getInt(row, col); } return outgoing; }
public int[] getIntRow(int row) { int[] outgoing = new int[columns.length]; for (int col = 0; col < columns.length; col++) { outgoing[col] = getInt(row, col); } return outgoing; }
public int[] getIntColumn(int col) { int[] outgoing = new int[rowCount]; for (int row = 0; row < rowCount; row++) { outgoing[row] = getInt(row, col); } return outgoing; }
public int getInt(int column) { return table.getInt(row, column); }
public int getInt(String columnName) { return table.getInt(row, columnName); }
public int getInt(String columnName) { return table.getInt(row, columnName); }
public int getInt(int column) { return table.getInt(row, column); }
/** * @param columnName title of the column to reference */ public int getInt(int row, String columnName) { return getInt(row, getColumnIndex(columnName)); }
/** * @param columnName title of the column to reference */ public int getInt(int row, String columnName) { return getInt(row, getColumnIndex(columnName)); }
/** * Get a String value from the table. If the row is longer than the table * * @webref table:method * @brief Get an String value from the specified row and column * @param row ID number of the row to reference * @param column ID number of the column to reference * @see Table#getInt(int, int) * @see Table#getFloat(int, int) * @see Table#getStringColumn(String) * @see Table#setInt(int, int, int) * @see Table#setFloat(int, int, float) * @see Table#setString(int, int, String) */ public String getString(int row, int column) { checkBounds(row, column); if (columnTypes[column] == STRING) { String[] stringData = (String[]) columns[column]; return stringData[row]; } else if (columnTypes[column] == CATEGORY) { int cat = getInt(row, column); if (cat == missingCategory) { return missingString; } return columnCategories[column].key(cat); } else { return String.valueOf(Array.get(columns[column], row)); } }
@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)); } }
return stringData[row]; } else if (columnTypes[column] == CATEGORY) { int cat = getInt(row, column); if (cat == missingCategory) { return missingString;
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; }