/** * Trims the capacity of the receiver to be the receiver's current size. Releases any superfluous internal memory. An * application can use this operation to minimize the storage of the receiver. */ @Override public void trimToSize() { // * 1.2 because open addressing's performance exponentially degrades beyond that point // so that even rehashing the table can take very long int newCapacity = nextPrime((int) (1 + 1.2 * size())); if (table.length > newCapacity) { rehash(newCapacity); } }
@Test public void testClone() { OpenIntLongHashMap map = new OpenIntLongHashMap(); map.put((int) 11, (long) 22); OpenIntLongHashMap map2 = (OpenIntLongHashMap) map.clone(); map.clear(); assertEquals(1, map2.size()); }
@Test public void testCopy() { OpenIntLongHashMap map = new OpenIntLongHashMap(); map.put((int) 11, (long) 22); OpenIntLongHashMap map2 = (OpenIntLongHashMap) map.copy(); map.clear(); assertEquals(1, map2.size()); }
/** * Trims the capacity of the receiver to be the receiver's current size. Releases any superfluous internal memory. An * application can use this operation to minimize the storage of the receiver. */ @Override public void trimToSize() { // * 1.2 because open addressing's performance exponentially degrades beyond that point // so that even rehashing the table can take very long int newCapacity = nextPrime((int) (1 + 1.2 * size())); if (table.length > newCapacity) { rehash(newCapacity); } }
/** * Trims the capacity of the receiver to be the receiver's current size. Releases any superfluous internal memory. An * application can use this operation to minimize the storage of the receiver. */ @Override public void trimToSize() { // * 1.2 because open addressing's performance exponentially degrades beyond that point // so that even rehashing the table can take very long int newCapacity = nextPrime((int) (1 + 1.2 * size())); if (table.length > newCapacity) { rehash(newCapacity); } }