I'm pretty new to Java so sorry if this is super basic. Basically I have some data in a array list and it works fine but in a later part of my program I need to read the list and it takes a long time because the list becomes very large. So I thought I could take certain parts of the array list(thats needed later) into a hash map that I can extract that section of the array list later from(hopefully that makes sense).
I first create the array list with all the data I want(I have a loop and call each data thats created in a single loop data_cache_local_loop):
HashMap hashmap_of_values = new HashMap(); //hashmap of arraylist
for (int i = 0; i<100; i++) {
....program logic and more loops
Set uniqie_T_cache = new HashSet(T_cache_local_loop); //make values unique
hashmap_of_values.put(i, new ArrayList(uniqie_T_cache));
}
Then later on when I need the data I extract it like this:
List t = new ArrayList();
t.add(hashmap_of_values.get(i));
But my program fails and I'm not sure exactly why. When I print out the size of hashmap_of_values I get the number of i's I'm expecting but when I print out the number of T it only shows one(when I run the program it says T_cache_local_loop has hundreds of items).
Can anyone suggest to me what I'm doing wrong? I'm not 100% but I think I maybe looking at the array list I add as a single item but I'm unsure of what I'm doing wrong.