Bartholomew Benson wrote:Basically, I want to create a generic table where the key is an enum type that extends ComponentType, and the value is a class that extends Component.
Bartholomew Benson wrote:Hmm, ultimately, what I would like to do is to make this table a generic table; I plan to have multiple types of components, like maybe CarComponents vs BicycleComponents. Each one would have its own table. Might it fix the problem to declare ArrayList<EnumMap<? extends ComponentType,? extends Component>> table, then instantiate it as, new ArrayList<EnumMap<K,V>(), where K and V are some classes that inherit ComponentType and Component respectively?
Bartholomew Benson wrote:Basically, I'd like to implement something structured sort of like a relational database, where the columns are the entry's components, and each entry in memory has an int id that fetches that class's fields as an EnumMap, where every EnumMap represents a row of the table.
However, I can't use a java SQL library unless its access speed is on par with direct array access, since I'm expected to constantly read/write this table as fast as I can. ArrayLists seem to be fast enough for most purposes, and I was told that EnumMap is supposed to be a very efficient HashMap using enum keys, so that's why I decided to make it a list of EnumMaps.