I need a data structure to store a number of integer values associated with an array of strings of variable size. For example, this is what I have-
ADDRESS INSTRUCTION
64 ADD R1, R0, R0
68 BGTZ R2, #32
. .
. .
. .
124 J #116
where I want to fetch an INSTRUCTION which I suppose should be stored as an array of strings(exclude the comma and '#') based on the ADDRESS value, more like a key-value pair. This is what I think should be a good idea to store it OR if you can suggest me a better approach of representing this in memory it would be great. (I am using Java to code.)
A good data structure(WHICH?) with reasoning(WHY?) and a detailed explanation(HOW?) would be really nice.
WHICH?
Map<Integer, List<String>>
WHY?
HOW?
Map<Integer, List<String>> map = new HashMap<>();
map.put(64, new ArrayList<String>());
map.get(64).addAll("ADD", "R1", "R0", "R0");
PROFIT!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With