/** * Ensures that the receiver can hold at least the specified number of associations without needing to allocate new * internal memory. If necessary, allocates new internal memory and increases the capacity of the receiver. <p> This * method never need be called; it is for performance tuning only. Calling this method before <tt>put()</tt>ing a * large number of associations boosts performance, because the receiver will grow only once instead of potentially * many times and hash collisions get less probable. * * @param minCapacity the desired minimum capacity. */ @Override public void ensureCapacity(int minCapacity) { if (table.length < minCapacity) { int newCapacity = nextPrime(minCapacity); 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); } }
int capacity = initialCapacity; super.setUp(capacity, minLoadFactor, maxLoadFactor); capacity = nextPrime(capacity); if (capacity == 0) { capacity = 1;
/** * Ensures that the receiver can hold at least the specified number of associations without needing to allocate new * internal memory. If necessary, allocates new internal memory and increases the capacity of the receiver. <p> This * method never need be called; it is for performance tuning only. Calling this method before <tt>put()</tt>ing a * large number of associations boosts performance, because the receiver will grow only once instead of potentially * many times and hash collisions get less probable. * * @param minCapacity the desired minimum capacity. */ @Override public void ensureCapacity(int minCapacity) { if (table.length < minCapacity) { int newCapacity = nextPrime(minCapacity); rehash(newCapacity); } }
/** * Ensures that the receiver can hold at least the specified number of associations without needing to allocate new * internal memory. If necessary, allocates new internal memory and increases the capacity of the receiver. <p> This * method never need be called; it is for performance tuning only. Calling this method before <tt>put()</tt>ing a * large number of associations boosts performance, because the receiver will grow only once instead of potentially * many times and hash collisions get less probable. * * @param minCapacity the desired minimum capacity. */ @Override public void ensureCapacity(int minCapacity) { if (table.length < minCapacity) { int newCapacity = nextPrime(minCapacity); 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); } }
/** * 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); } }
int capacity = initialCapacity; super.setUp(capacity, minLoadFactor, maxLoadFactor); capacity = nextPrime(capacity); if (capacity == 0) { capacity = 1;
int capacity = initialCapacity; super.setUp(capacity, minLoadFactor, maxLoadFactor); capacity = nextPrime(capacity); if (capacity == 0) { capacity = 1;