| 66 | } |
| 67 | |
| 68 | private void resize(int capacity) { |
| 69 | Cell<K, V>[] newArray = null; |
| 70 | if (capacity != 0) { |
| 71 | capacity = Data.nextPowerOfTwo(capacity); |
| 72 | if (array != null && array.length == capacity) { |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | newArray = new Cell[capacity]; |
| 77 | if (array != null) { |
| 78 | for (int i = 0; i < array.length; ++i) { |
| 79 | Cell<K, V> next; |
| 80 | for (Cell<K, V> c = array[i]; c != null; c = next) { |
| 81 | next = c.next(); |
| 82 | int index = c.hashCode() & (capacity - 1); |
| 83 | c.setNext(newArray[index]); |
| 84 | newArray[index] = c; |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | array = newArray; |
| 90 | } |
| 91 | |
| 92 | protected Cell<K, V> find(Object key) { |
| 93 | if (array != null) { |