Any particular reason you are mapping the values to the indices (as an ArrayList<Integer>) instead of to the objects (as an ArrayList<Object>) themselves? As Objects are always references in Java (just like `Object*` in C++), there is no space nor speed benefit in storing integers instead of Objects here, especially since it looks as if you dereference them in any cases anyway.