List2dpublic class List2d extends Object Provides an interface for interacting with 2d arrays of objects. This
implementation will return null for items not yet allocated and automatically
increase the array size for set operations. You never get an index out of
bounds. |
Methods Summary |
---|
public java.lang.Object | get(int col, int row)
if (row >= rows.size())
{
return null;
}
else
{
List cols = (List) rows.get(row);
if (col >= cols.size())
return null;
else
return cols.get( col );
}
| private void | resizeCols(int row, int col)
List cols = (List) rows.get( row );
while (cols.size() <= col)
cols.add(null);
| private void | resizeRows(int row)
while (rows.size() <= row)
rows.add( new ArrayList() );
| public void | set(int col, int row, java.lang.Object value)
resizeRows(row);
resizeCols(row,col);
List cols = (List) rows.get( row );
cols.set( col, value );
|
|