views:

133

answers:

3

I searched around on Google, but I was unable to find any libraries for a multi-dimensional container in Java (preferably one that supports generics as well). I could easily write one (in fact, I have started to), but I was hoping that I would be able to reuse the work someone else has done for the sake of efficiency. I don't necessarily need to provide any sort of additional functionality outside of the "container" realm (AKA, no matrix functionality for example).

Does anybody know of any type of class/library for a multi-dimensional container? Thanks!

Edit: To clarify, yes, I am looking for a Collection of Collections of Collections ... (or int[][][][][], etc). Essentially, a multi-dimensional array.

+1  A: 

Can't you use a jagged array (eg int[][])?

You can make it n-dimensional (int[][][][]), but it starts to get silly after a while

thecoop
you really can't imagine a four-dimensional array? ;-)
Andreas_D
@thecoop - This is essentially what I want. However, I need the array to be able to grow at a later time (add additional dimensions, as well as add values within the already existing dimensions). That's why I was hoping to utilize the Collections framework.
JasCav
That'll be a List<List<Integer>> then
thecoop
+3  A: 

Something like this, a Collection of Collections?

Collection<Collection<Object>> multiDimensional = 
                     new ArrayList<Collection<Object>>();

Or something completely different?

Andreas_D
+3  A: 

Google Collections supports multimaps and multisets (bags). Is that what you mean?

Jonathan Feinberg