@Test public void testEntries() { LongHashMap map = new LongHashMap(); map.put(0, "a"); map.put(-98, "b"); map.put(666, "c"); map.put(Long.MAX_VALUE, "d"); map.remove(666); LongHashMap.Entry[] entries = map.entries(); assertEquals(3, entries.length); String all = ""; for (LongHashMap.Entry entry : entries) { all += "(" + entry.key + "=" + entry.value + ")"; } assertTrue(all, all.contains("(0=a)")); assertTrue(all, all.contains("(-98=b)")); assertTrue(all, all.contains("(" + Long.MAX_VALUE + "=d)")); }
public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; }
LongHashMap { public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; } }
LongHashMap { public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; } LongHashMap(); @SuppressWarnings("unchecked")  LongHashMap(int capacity); }
LongHashMap { public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; } LongHashMap(); @SuppressWarnings("unchecked")  LongHashMap(int capacity); static LongHashMap<T> createSynchronized(); static LongHashMap<T> createSynchronized(int capacity); boolean containsKey(long key); T get(long key); T put(long key, T value); T remove(long key); long[] keys(); Entry<T>[] entries(); void clear(); int size(); void setCapacity(int newCapacity); void reserveRoom(int entryCount); }
LongHashMap { public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; } LongHashMap(); @SuppressWarnings("unchecked")  LongHashMap(int capacity); static LongHashMap<T> createSynchronized(); static LongHashMap<T> createSynchronized(int capacity); boolean containsKey(long key); T get(long key); T put(long key, T value); T remove(long key); long[] keys(); Entry<T>[] entries(); void clear(); int size(); void setCapacity(int newCapacity); void reserveRoom(int entryCount);  }