This here's a conundrum I've been trying to slog through for some time now. Part of it is a decided dislike of List type objects and part of it is issues with the way Generics work in Java. Here's the problem:
The game I'm designing is going to use an map using X dimensions (Where X >= 1). This base map is most easily described as a dense rectangular array (For X == 2), or a dense cubic array (For X == 3), etc. On "Top" of this is a very sparse map, with the same dimensions of the previous map, and on top of that can be another sparse map, and on top of that can be another, ad nauseum.
Here's a cobbled together example:
Layer 1 (Dense): Physical description of world
Layer 2 (Sparse): Location of hidden items
Layer 3 (Sparse): Location of special ground effects (Think this area is on fire/occupied by poison gas)
Layer 4 (Sparse): Location of Entities
For the most part, the Sparse maps are fairly simple to use Generics for. A HashMap<Position, T> takes care of it. For the Dense map on the bottom, it becomes more difficult to use Generics for, since
T map = new T[x];
is a violation. However, using ArrayList<ArrayList<T>> leads to problems with replacement/excess size issues. HashMap<Position, T> may work, but again, since there's going to be a static number of values in the map it seems like a waste.
Are there already any 'good', for a given value of good or reason, replacement for dense two-dimensional staticly sized arrays?