MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / putImpl

Method putImpl

vm/JavaAPI/src/java/util/HashMap.java:529–556  ·  view source on GitHub ↗
(K key, V value)

Source from the content-addressed store, hash-verified

527 }
528
529 V putImpl(K key, V value) {
530 Entry<K,V> entry;
531 if(key == null) {
532 entry = findNullKeyEntry();
533 if (entry == null) {
534 modCount++;
535 entry = createHashedEntry(null, 0, 0);
536 if (++elementCount > threshold) {
537 rehash();
538 }
539 }
540 } else {
541 int hash = computeHashCode(key);
542 int index = hash & (elementData.length - 1);
543 entry = findNonNullKeyEntry(key, index, hash);
544 if (entry == null) {
545 modCount++;
546 entry = createHashedEntry(key, index, hash);
547 if (++elementCount > threshold) {
548 rehash();
549 }
550 }
551 }
552
553 V result = entry.value;
554 entry.value = value;
555 return result;
556 }
557
558 Entry<K, V> createEntry(K key, int index, V value) {
559 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