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

Method putImpl

Ports/CLDC11/src/java/util/HashMap.java:542–569  ·  view source on GitHub ↗
(K key, V value)

Source from the content-addressed store, hash-verified

540 }
541
542 V putImpl(K key, V value) {
543 Entry<K,V> entry;
544 if(key == null) {
545 entry = findNullKeyEntry();
546 if (entry == null) {
547 modCount++;
548 entry = createHashedEntry(null, 0, 0);
549 if (++elementCount > threshold) {
550 rehash();
551 }
552 }
553 } else {
554 int hash = computeHashCode(key);
555 int index = hash & (elementData.length - 1);
556 entry = findNonNullKeyEntry(key, index, hash);
557 if (entry == null) {
558 modCount++;
559 entry = createHashedEntry(key, index, hash);
560 if (++elementCount > threshold) {
561 rehash();
562 }
563 }
564 }
565
566 V result = entry.value;
567 entry.value = value;
568 return result;
569 }
570
571 Entry<K, V> createEntry(K key, int index, V value) {
572 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