tags:

views:

90

answers:

3

I was wondering what is the quickest way of storing a byte[] with an integer index in java without using Maps, TreeMap, ArrayLists etc.

i.e. not like this:

private Map<Integer, byte[]> example = new TreeMap()
+2  A: 
private byte[][] example;
example = new byte[][ARRAYS_COUNT];
example[0] = new byte[10];
example[1] = new byte[20];
...
DNNX
He wanted to hold them with an **integer** index.
BalusC
I don't know how would you use this data structure so can't say for sure is this more efficient or not. For example, if you want to store 3 byte arrays with indexes, say, 0, 1 and 10000000, this is definitely less efficient than TreeMap.
DNNX
A: 

How about byte[][] and resize as appropriate? Not as good as an ArrayList but you banned that...

Mark Byers
+1  A: 

Quickest way would be an ArrayList<byte[]>, or you want or not. A byte[][] isn't going to work as you can then hold only 28-1 arrays, not 232-1 as you could with an integer index which you explicitly mentioned in your question.

BalusC
Ah yes ArrayLists, I think ill try a few and see whats quickest. Thanks
Hugh