My Java code:
if(wins.containsKey(winner)) {
int currentCount = wins.get(winner);
wins.remove(winner);
wins.put(winner, currentCount + 1);
} else {
wins.put(winner, 1);
}
This was my alternative to something I can do in PHP and even C#:
if(isset($something[$key])) {
$something[$key]++;
} else {
$something[$key] = 1;
}
This is going to be used in a high number of iterations in a for loop so I would like to consider performance. Is this whole remove() then puts() business killing the performance? What is an alternative?
winsisn't an array (as the title states). With arrays in Java, you can happily use[].