Puts the given entry in the #entries hash set. This method does not check whether #entries already contains a similar entry or not. #entries is resized if necessary to avoid hash collisions (multiple entries needing to be stored at the same #entries array index
(final Entry entry)
| 418 | * @return the given entry |
| 419 | */ |
| 420 | private Entry put(final Entry entry) { |
| 421 | if (entryCount > (entries.length * 3) / 4) { |
| 422 | int currentCapacity = entries.length; |
| 423 | int newCapacity = currentCapacity * 2 + 1; |
| 424 | Entry[] newEntries = new Entry[newCapacity]; |
| 425 | for (int i = currentCapacity - 1; i >= 0; --i) { |
| 426 | Entry currentEntry = entries[i]; |
| 427 | while (currentEntry != null) { |
| 428 | int newCurrentEntryIndex = currentEntry.hashCode % newCapacity; |
| 429 | Entry nextEntry = currentEntry.next; |
| 430 | currentEntry.next = newEntries[newCurrentEntryIndex]; |
| 431 | newEntries[newCurrentEntryIndex] = currentEntry; |
| 432 | currentEntry = nextEntry; |
| 433 | } |
| 434 | } |
| 435 | entries = newEntries; |
| 436 | } |
| 437 | entryCount++; |
| 438 | int index = entry.hashCode % entries.length; |
| 439 | entry.next = entries[index]; |
| 440 | return entries[index] = entry; |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Adds the given entry in the {@link #entries} hash set. This method does <i>not</i> check |
no outgoing calls
no test coverage detected