(K key, V value)
| 375 | } |
| 376 | |
| 377 | V putImpl(K key, V value) { |
| 378 | LinkedHashMapEntry<K, V> m; |
| 379 | if (elementCount == 0) { |
| 380 | head = tail = null; |
| 381 | } |
| 382 | if (key == null) { |
| 383 | m = (LinkedHashMapEntry<K, V>) findNullKeyEntry(); |
| 384 | if (m == null) { |
| 385 | modCount++; |
| 386 | // Check if we need to remove the oldest entry. The check |
| 387 | // includes accessOrder since an accessOrder LinkedHashMap does |
| 388 | // not record the oldest member in 'head'. |
| 389 | if (++elementCount > threshold) { |
| 390 | rehash(); |
| 391 | } |
| 392 | m = (LinkedHashMapEntry<K, V>) createHashedEntry(null, 0, 0); |
| 393 | } else { |
| 394 | linkEntry(m); |
| 395 | } |
| 396 | } else { |
| 397 | int hash = key.hashCode(); |
| 398 | int index = (hash & 0x7FFFFFFF) % elementData.length; |
| 399 | m = (LinkedHashMapEntry<K, V>) findNonNullKeyEntry(key, index, hash); |
| 400 | if (m == null) { |
| 401 | modCount++; |
| 402 | if (++elementCount > threshold) { |
| 403 | rehash(); |
| 404 | index = (hash & 0x7FFFFFFF) % elementData.length; |
| 405 | } |
| 406 | m = (LinkedHashMapEntry<K, V>) createHashedEntry(key, index, |
| 407 | hash); |
| 408 | } else { |
| 409 | linkEntry(m); |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | V result = m.value; |
| 414 | m.value = value; |
| 415 | return result; |
| 416 | } |
| 417 | |
| 418 | /* |
| 419 | * @param m |
no test coverage detected