MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / rehash

Method rehash

vm/JavaAPI/src/java/util/Hashtable.java:744–772  ·  view source on GitHub ↗

Increases the capacity of this Hashtable. This method is called when the size of this Hashtable exceeds the load factor.

()

Source from the content-addressed store, hash-verified

742 * when the size of this {@code Hashtable} exceeds the load factor.
743 */
744 protected void rehash() {
745 int length = (elementData.length << 1) + 1;
746 if (length == 0) {
747 length = 1;
748 }
749 int newFirst = length;
750 int newLast = -1;
751 Entry<K, V>[] newData = newElementArray(length);
752 for (int i = lastSlot + 1; --i >= firstSlot;) {
753 Entry<K, V> entry = elementData[i];
754 while (entry != null) {
755 int index = (entry.getKeyHash() & 0x7FFFFFFF) % length;
756 if (index < newFirst) {
757 newFirst = index;
758 }
759 if (index > newLast) {
760 newLast = index;
761 }
762 Entry<K, V> next = entry.next;
763 entry.next = newData[index];
764 newData[index] = entry;
765 entry = next;
766 }
767 }
768 firstSlot = newFirst;
769 lastSlot = newLast;
770 elementData = newData;
771 computeMaxSize();
772 }
773
774 /**
775 * Removes the key/value pair with the specified key from this

Callers 2

putMethod · 0.95
putImplMethod · 0.45

Calls 3

newElementArrayMethod · 0.95
computeMaxSizeMethod · 0.95
getKeyHashMethod · 0.45

Tested by

no test coverage detected