So, I’m implementing my input handler in LWJGL3, doing it on my own (no references) just for the heck of it.
I need to be able to keep track of how long keys have been held down, and my first instinct is to have an array of integers keeping track of the “down” time of individual keys (more precisely, keeping track of the start time).
public static int[] keys_time = new int[65536];
···
keys_time[key_code] = start_time;
If my calculations are correct, for integers being 32-bits long, just declaring that array takes around 262Kb.
My question here is… Is this a waste of space? Are 262Kb too much? Would it be worth it to do something like this:
public static HashMap<Integer, Integer> keys_time = new HashMap<Integer, Integer>();
···
keys_time.put(key_code, start_time);
My intention here is not to discuss about keyboard handlers (I’ll check documentation on that later today), but to discuss the ramifications of making design decisions like the above.