Hi I got a question on whether to use an ArrayList or HashMap.
I am trying to build a Paint program. Each drawn object will be assigned a unique object ID.
If I want a fast retrieval speed when I click on an object, should I be using an arraylist or hashmap?
In general hashmap has O(1) while arraylist has O(n) retrieval speed.
However, I think for my case, since when I click on an object, I'll get the ID, hence the index of the array and I can do something like ArraylistObject.get(ithElement); , so in this case this will also be a O(1) retrieval process?
any inputs?
Thanks!