/** * {@inheritDoc} */ public boolean isEmpty() { return Int2IntHashMap.this.isEmpty(); }
/** * {@inheritDoc} */ public boolean isEmpty() { return Int2IntHashMap.this.isEmpty(); }
/** * {@inheritDoc} */ public String toString() { if (isEmpty()) { return "{}"; } final EntryIterator entryIterator = new EntryIterator(); entryIterator.reset(); final StringBuilder sb = new StringBuilder().append('{'); while (true) { entryIterator.next(); sb.append(entryIterator.getIntKey()).append('=').append(entryIterator.getIntValue()); if (!entryIterator.hasNext()) { return sb.append('}').toString(); } sb.append(',').append(' '); } }
@Test public void correctSizeAfterRehash() { final Int2IntHashMap map = new Int2IntHashMap(16, 0.6f, -1); IntStream.range(1, 17).forEach((i) -> map.put(i, i)); assertEquals("Map has correct size", 16, map.size()); final List<Integer> keys = new ArrayList<>(map.keySet()); keys.forEach(map::remove); assertTrue("Map isn't empty", map.isEmpty()); }
@Test public void correctSizeAfterRehash() { final Int2IntHashMap map = new Int2IntHashMap(16, 0.6f, -1); IntStream.range(1, 17).forEach((i) -> map.put(i, i)); assertEquals("Map has correct size", 16, map.size()); final List<Integer> keys = new ArrayList<>(map.keySet()); keys.forEach(map::remove); assertTrue("Map isn't empty", map.isEmpty()); }
@Test public void shouldInitiallyBeEmpty() { assertEquals(0, map.size()); assertTrue(map.isEmpty()); }
@Test public void clearShouldResetSize() { map.put(1, 1); map.put(100, 100); map.clear(); assertEquals(0, map.size()); assertTrue(map.isEmpty()); }
@SuppressWarnings("ConstantConditions") @Test public void removeShouldRemoveEntry() { map.put(1, 2); map.remove(1); assertTrue(map.isEmpty()); assertFalse(map.containsKey(1)); assertFalse(map.containsValue(2)); }
/** * {@inheritDoc} */ public boolean isEmpty() { return Int2IntHashMap.this.isEmpty(); }
/** * {@inheritDoc} */ public boolean isEmpty() { return Int2IntHashMap.this.isEmpty(); }
public boolean hasEntries() { return !entries.isEmpty(); } }
public boolean hasEntries() { return !entries.isEmpty(); } }
/** * {@inheritDoc} */ public String toString() { if (isEmpty()) { return "{}"; } final EntryIterator entryIterator = new EntryIterator(); entryIterator.reset(); final StringBuilder sb = new StringBuilder().append('{'); while (true) { entryIterator.next(); sb.append(entryIterator.getIntKey()).append('=').append(entryIterator.getIntValue()); if (!entryIterator.hasNext()) { return sb.append('}').toString(); } sb.append(',').append(' '); } }