Nested HashMap performance.
HashMap I have the following:
HashMap <String, HashMap <String, HashMap <String,String>>> table = new HashMap <String, HashMap <String, HashMap <String, String> >>();
this is right?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
↑ perfectly fine.
In terms of nesting the HashMaps, a better option might be to concatenate the keys and use a non-nested HashMap if you’re typically interested in the end values and not the intermediate maps.
…in other words, define a
Tripleclass with three strings, and define a hashcode and equals method, etc. Then use:…again, this assumes that your lookup operation takes three strings and returns one value.
To do lookups on
table1, you need to do:To do lookups on
table2, you need to do:(…FWIW, doing inserts on
table2is must easier).