/** * Convenience version of {@link #getAndAdd(long, long)} (key, 1). * * @param key for the counter. * @return the old value. */ public long getAndIncrement(final long key) { return getAndAdd(key, 1); }
/** * Convenience version of {@link #getAndAdd(long, long)} (key, -1). * * @param key for the counter. * @return the old value. */ public long getAndDecrement(final long key) { return getAndAdd(key, -1); }
/** * Add amount to the current value associated with this key. If no such value exists use {@link #initialValue()} as * current value and associate key with {@link #initialValue()} + amount unless amount is 0, in which case map * remains unchanged. * * @param key new or existing * @param amount to be added * @return the new value associated with the specified key, or * {@link #initialValue()} + amount if there was no mapping for the key. */ public long addAndGet(final long key, final long amount) { return getAndAdd(key, amount) + amount; }