MCPcopy Create free account
hub / github.com/davidgiven/luje / putImpl

Method putImpl

lib/java/util/HashMap.java:562–589  ·  view source on GitHub ↗
(K key, V value)

Source from the content-addressed store, hash-verified

560 }
561
562 V putImpl(K key, V value) {
563 Entry<K,V> entry;
564 if(key == null) {
565 entry = findNullKeyEntry();
566 if (entry == null) {
567 modCount++;
568 entry = createHashedEntry(null, 0, 0);
569 if (++elementCount > threshold) {
570 rehash();
571 }
572 }
573 } else {
574 int hash = computeHashCode(key);
575 int index = hash & (elementData.length - 1);
576 entry = findNonNullKeyEntry(key, index, hash);
577 if (entry == null) {
578 modCount++;
579 entry = createHashedEntry(key, index, hash);
580 if (++elementCount > threshold) {
581 rehash();
582 }
583 }
584 }
585
586 V result = entry.value;
587 entry.value = value;
588 return result;
589 }
590
591 Entry<K, V> createEntry(K key, int index, V value) {
592 Entry<K, V> entry = new Entry<K, V>(key, value);

Callers 2

putMethod · 0.95
putAllImplMethod · 0.95

Calls 5

findNullKeyEntryMethod · 0.95
createHashedEntryMethod · 0.95
rehashMethod · 0.95
computeHashCodeMethod · 0.95
findNonNullKeyEntryMethod · 0.95

Tested by

no test coverage detected