()
| 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`. |
no test coverage detected