/** * {@inheritDoc} */ public Integer remove(final Object key) { return valOrNull(remove((int)key)); }
@Test public void removeShouldReturnMissing() { assertEquals(MISSING_VALUE, map.remove(1)); }
@Test public void shouldOnlyRemoveTheSpecifiedEntry() { IntStream.range(0, 8).forEach((i) -> map.put(i, i * 2)); map.remove(5); IntStream .range(0, 8) .filter((i) -> i != 5L) .forEach((i) -> { assertTrue(map.containsKey(i)); assertTrue(map.containsValue(2 * i)); }); }
@Test public void removeShouldReturnValueRemoved() { map.put(1, 2); assertEquals(2, map.remove(1)); }
@SuppressWarnings("ConstantConditions") @Test public void removeShouldRemoveEntry() { map.put(1, 2); map.remove(1); assertTrue(map.isEmpty()); assertFalse(map.containsKey(1)); assertFalse(map.containsValue(2)); }
@Test public void shouldAllowMissingValueAsKey() { map.put(MISSING_VALUE, 1); assertEquals(1, map.get(MISSING_VALUE)); assertTrue(map.containsKey(MISSING_VALUE)); assertEquals(1, map.size()); final int[] tuple = new int[2]; map.intForEach((k, v) -> { tuple[0] = k; tuple[1] = v; }); assertEquals(MISSING_VALUE, tuple[0]); assertEquals(1, tuple[1]); assertEquals(1, map.remove(MISSING_VALUE)); assertEquals(0, map.size()); assertEquals(MISSING_VALUE, map.get(MISSING_VALUE)); }
/** * {@inheritDoc} */ public Integer remove(final Object key) { return remove((int)key); }
/** * {@inheritDoc} */ public Integer remove(final Object key) { return valOrNull(remove((int)key)); }