Correctly return the new count from add().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2706 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -52,14 +52,14 @@ public class CountMap<K> extends AbstractMap<K, Integer>
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified amount to the count for the specified key.
|
||||
* Add the specified amount to the count for the specified key, return the new count.
|
||||
*/
|
||||
public int add (K key, int amount)
|
||||
{
|
||||
CountEntry<K> entry = _backing.get(key);
|
||||
if (entry == null) {
|
||||
_backing.put(key, entry = new CountEntry<K>(key, amount));
|
||||
return 0;
|
||||
return amount;
|
||||
}
|
||||
return (entry.count += amount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user