{@inheritDoc}
(Object key)
| 179 | |
| 180 | /** {@inheritDoc} */ |
| 181 | @Override |
| 182 | public V remove(Object key) { |
| 183 | if (key != null) { |
| 184 | if (innerMap != null) { |
| 185 | V value = innerMap.remove(key); |
| 186 | if (value != null) { |
| 187 | size = innerMap.size(); |
| 188 | if (size <= keys.length) { // devolve |
| 189 | size = 0; Set<Entry<K,V>> entries = innerMap.entrySet(); innerMap = null; |
| 190 | for (Entry<? extends K, ? extends V> entry : entries) { |
| 191 | int i = size++; // not atomic |
| 192 | values[i] = entry.getValue(); |
| 193 | keys[i] = entry.getKey(); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | return value; |
| 198 | } |
| 199 | for (int i = 0; i < size; i += 1) { |
| 200 | if (key.equals(keys[i])) { |
| 201 | V value = values[i]; |
| 202 | int j = (size -= 1); |
| 203 | // if last element is not being removed, shift the last element into this slot |
| 204 | if (i < j) { |
| 205 | values[i] = values[j]; |
| 206 | keys[i] = keys[j]; |
| 207 | } |
| 208 | values[j] = null; |
| 209 | keys[j] = null; |
| 210 | return value; |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | return null; |
| 215 | } |
| 216 | |
| 217 | /** {@inheritDoc} */ |
| 218 | @Override |