It sounds like you want to use a row-key, a col-key, and then the value at that location. There's no builtin data structure that'll do that for you.
The easiest thing to use may be a 2d array for the actual data. Use something like the following to go from a row or column name to the actual index in your array. Add as many name-to-index bindings as you want.
Map<String, Integer> rows = new HashMap<String, Integer>();
Map<String, Integer> cols = new HashMap<String, Integer>();
Then getting that value in the grid...
grid[rows.get("Row name")][cols.get("Column name")];
Put the grid and a get(String rowName, String colName)
method in a class if you want a cleaner API.
Edit: I see the question has been updated, and it looks like the name-to-index pairs are the same for both rows and columns. So here's an updated version:
class SquareMap<V> {
private V[][] grid;
private Map<String, Integer> indexes;
public SquareMap(int size) {
grid = (V[][]) new Object[size][size];
indexes = new HashMap<String, Integer>();
}
public void setIndex(String name, int index) {
indexes.put(name, index);
}
public void set(String row, String col, V value) {
grid[indexes.get(row)][indexes.get(col)] = value;
}
public V get(String row, String col) {
return grid[indexes.get(row)][indexes.get(col)];
}
}