testing out a lookup function

This commit is contained in:
Ben Fry
2016-08-27 11:01:16 -04:00
parent a09aa5a88f
commit 7a80b16237
2 changed files with 24 additions and 2 deletions

View File

@@ -4418,13 +4418,13 @@ public class Table {
public FloatDict getFloatDict(int keyColumn, int valueColumn) {
return new FloatDict(getStringColumn(keyColumn),
getFloatColumn(valueColumn));
getFloatColumn(valueColumn));
}
public StringDict getStringDict(String keyColumnName, String valueColumnName) {
return new StringDict(getStringColumn(keyColumnName),
getStringColumn(valueColumnName));
getStringColumn(valueColumnName));
}
@@ -4434,6 +4434,26 @@ public class Table {
}
public Map<String, TableRow> getRowMap(String columnName) {
int col = getColumnIndex(columnName);
return (col == -1) ? null : getRowMap(col);
}
public Map<String, TableRow> getRowMap(int column) {
Map<String, TableRow> outgoing = new HashMap<>();
for (int row = 0; row < getRowCount(); row++) {
String id = getString(row, column);
outgoing.put(id, new RowPointer(this, row));
}
// for (TableRow row : rows()) {
// String id = row.getString(column);
// outgoing.put(id, row);
// }
return outgoing;
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .