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

Method put

Ports/CLDC11/src/java/util/Hashtable.java:737–768  ·  view source on GitHub ↗
(K key, V value)

Source from the content-addressed store, hash-verified

735 ///
736 /// - java.lang.Object#equals
737 @Override
738 public synchronized V put(K key, V value) {
739 if (key != null && value != null) {
740 int hash = key.hashCode();
741 int index = (hash & 0x7FFFFFFF) % elementData.length;
742 Entry<K, V> entry = elementData[index];
743 while (entry != null && !entry.equalsKey(key, hash)) {
744 entry = entry.next;
745 }
746 if (entry == null) {
747 modCount++;
748 if (++elementCount > threshold) {
749 rehash();
750 index = (hash & 0x7FFFFFFF) % elementData.length;
751 }
752 if (index < firstSlot) {
753 firstSlot = index;
754 }
755 if (index > lastSlot) {
756 lastSlot = index;
757 }
758 entry = newEntry(key, value, hash);
759 entry.next = elementData[index];
760 elementData[index] = entry;
761 return null;
762 }
763 V result = entry.value;
764 entry.value = value;
765 return result;
766 }
767 throw new NullPointerException();
768 }
769
770 /// Copies every mapping to this `Hashtable` from the specified map.
771 ///

Callers 13

putAllMethod · 0.95
actionPerformedMethod · 0.95
getContactByIdMethod · 0.95
getContactByIdMethod · 0.95
installNativeThemeMethod · 0.95
getContactMethod · 0.95
getAllContactsMethod · 0.95
installNativeThemeMethod · 0.95
getContactByIdMethod · 0.95
getContactByIdMethod · 0.95
createContactMethod · 0.95
initContactsMethod · 0.95

Calls 4

rehashMethod · 0.95
newEntryMethod · 0.95
hashCodeMethod · 0.65
equalsKeyMethod · 0.45

Tested by

no test coverage detected