/** * Convenience version of {@link #addAndGet(int, int)} (key, 1). * * @param key for the counter. * @return the new value. */ public int incrementAndGet(final int key) { return addAndGet(key, 1); }
/** * Convenience version of {@link #addAndGet(int, int)} (key, -1). * * @param key for the counter. * @return the new value. */ public int decrementAndGet(final int key) { return addAndGet(key, -1); }
@Test public void shouldContainValueForIncAndDecEntries() { map.incrementAndGet(1); map.getAndIncrement(2); map.getAndAdd(3, 2); map.addAndGet(4, 3); map.decrementAndGet(5); map.getAndDecrement(6); assertTrue(map.containsKey(1)); assertTrue(map.containsKey(2)); assertTrue(map.containsKey(3)); assertTrue(map.containsKey(4)); assertTrue(map.containsKey(5)); assertTrue(map.containsKey(6)); }
/** * Convenience version of {@link #addAndGet(int, int)} (key, 1). * * @param key for the counter. * @return the new value. */ public int incrementAndGet(final int key) { return addAndGet(key, 1); }
/** * Convenience version of {@link #addAndGet(int, int)} (key, -1). * * @param key for the counter. * @return the new value. */ public int decrementAndGet(final int key) { return addAndGet(key, -1); }