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

Method rehash

Ports/CLDC11/src/java/util/Hashtable.java:785–813  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

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