Are there effective 2D ArrayList classes for Java?

I know it is possible to create a 2D ArrayList with ArrayList<ArrayList<E>>, but it is cumbersome and real casting when it comes to adding and extracting objects.

Are there any 2D ArrayList classes that do this more efficiently? I am writing a real 2D ArrayList class from scratch, and I wonder if there is anyone else who would do this in efficient mode.

+5
source share
5 answers

no, unfortunately, there is no class 2 ArrayList. your alternatives (in case 0/1/2 Diamonds is permanent):

MyType[][] myList = new MyType[n][m];

or

ArrayList<MyType>[] myList = new ArrayList<MyType>[n];

or

ArrayList<ArrayList<MyType>> myList = new ArrayList<ArrayList<MyType>>();

- 1d ArrayList , (x, y) x ArrayList. 2d, 1d ArrayList

+4

"ArrayList > " , . 2D-, / .., "" " ", . . , , .

+1

FastTable javolution Table guava

+1

Google . / , bycol .

0
0

All Articles