MCPcopy Create free account
hub / github.com/davidgiven/luje / rehash

Method rehash

lib/java/util/Hashtable.java:780–808  ·  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

778 * when the size of this {@code Hashtable} exceeds the load factor.
779 */
780 protected void rehash() {
781 int length = (elementData.length << 1) + 1;
782 if (length == 0) {
783 length = 1;
784 }
785 int newFirst = length;
786 int newLast = -1;
787 Entry<K, V>[] newData = newElementArray(length);
788 for (int i = lastSlot + 1; --i >= firstSlot;) {
789 Entry<K, V> entry = elementData[i];
790 while (entry != null) {
791 int index = (entry.getKeyHash() & 0x7FFFFFFF) % length;
792 if (index < newFirst) {
793 newFirst = index;
794 }
795 if (index > newLast) {
796 newLast = index;
797 }
798 Entry<K, V> next = entry.next;
799 entry.next = newData[index];
800 newData[index] = entry;
801 entry = next;
802 }
803 }
804 firstSlot = newFirst;
805 lastSlot = newLast;
806 elementData = newData;
807 computeMaxSize();
808 }
809
810 /**
811 * Removes the key/value pair with the specified key from this

Callers 1

putMethod · 0.95

Calls 3

newElementArrayMethod · 0.95
computeMaxSizeMethod · 0.95
getKeyHashMethod · 0.80

Tested by

no test coverage detected