I have a Hashmap in Java like this:
private Map team1 = new HashMap();
Then I fill it like th
What I'll do which is very simple but waste memory is to map the values with a key and do the oposite to map the keys with a value making this:
private Map
it's important that you use
so you can map keys:Value
and Value:Keys
like this
team1.put("United", 5);
team1.put(5, "United");
So if you use team1.get("United") = 5
and team1.get(5) = "United"
But if you use some specific method on one of the objects in the pairs I'll be better if you make another map:
private Map
private Map
and then
team1.put("United", 5);
team1Keys.put(5, "United");
and remember, keep it simple ;)