(K key, V value)
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public V put(K key, V value) { |
| 109 | Objects.requireNonNull(value, NULL_VALUE_MSG); |
| 110 | int index = indexer.getIndex(key); |
| 111 | if (index >= 0) { |
| 112 | ensureCapacity(index); |
| 113 | V oldV = values[index]; |
| 114 | values[index] = value; |
| 115 | if (oldV == null) { |
| 116 | ++size; |
| 117 | } |
| 118 | return oldV; |
| 119 | } else { |
| 120 | throw new IllegalArgumentException("index of " + key + |
| 121 | " is negative: " + index); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | private void ensureCapacity(int index) { |
| 126 | int oldCapacity = values.length; |