/** * Returns the entry associated with the specified key in the * HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> getEntry(final K key) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null && !(e.hash == hash && keyComparatorEq(k, e.key))) { e = e.next; } return e; }
/** * Returns the entry associated with the specified key in the * HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> getEntry(final K key) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null && !(e.hash == hash && keyComparatorEq(k, e.key))) { e = e.next; } return e; }
/** * Returns <tt>true</tt> if this map contains a mapping for the * specified key. * * @param key The key whose presence in this map is to be tested * @return <tt>true</tt> if this map contains a mapping for the specified * key. */ @Override public boolean containsKey(final Object key) { final K k = (K) maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null) { if (e.hash == hash && keyComparatorEq(k, e.key)) { return true; } e = e.next; } return false; }
/** * Returns <tt>true</tt> if this map contains a mapping for the * specified key. * * @param key The key whose presence in this map is to be tested * @return <tt>true</tt> if this map contains a mapping for the specified * key. */ @Override public boolean containsKey(final Object key) { final K k = (K) maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null) { if (e.hash == hash && keyComparatorEq(k, e.key)) { return true; } e = e.next; } return false; }
final K k = maskNull(entry.getKey()); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length);
final K k = maskNull(entry.getKey()); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length);
/** * Returns the value to which the specified key is mapped in this identity * hash map, or <tt>null</tt> if the map contains no mapping for this key. * A return value of <tt>null</tt> does not <i>necessarily</i> indicate * that the map contains no mapping for the key; it is also possible that * the map explicitly maps the key to <tt>null</tt>. The * <tt>containsKey</tt> method may be used to distinguish these two cases. * * @param key the key whose associated value is to be returned. * @return the value to which this map maps the specified key, or * <tt>null</tt> if the map contains no mapping for this key. * @see #put(Object, Object) */ @Override public V get(final Object key) { final K k = (K) maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (true) { if (e == null) { return null; } if (e.hash == hash && keyComparatorEq(k, e.key)) { return e.value; } e = e.next; } }
/** * Returns the value to which the specified key is mapped in this identity * hash map, or <tt>null</tt> if the map contains no mapping for this key. * A return value of <tt>null</tt> does not <i>necessarily</i> indicate * that the map contains no mapping for the key; it is also possible that * the map explicitly maps the key to <tt>null</tt>. The * <tt>containsKey</tt> method may be used to distinguish these two cases. * * @param key the key whose associated value is to be returned. * @return the value to which this map maps the specified key, or * <tt>null</tt> if the map contains no mapping for this key. * @see #put(Object, Object) */ @Override public V get(final Object key) { final K k = (K) maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (true) { if (e == null) { return null; } if (e.hash == hash && keyComparatorEq(k, e.key)) { return e.value; } e = e.next; } }
/** * This method is used instead of put by constructors and * pseudoconstructors (clone, readObject). It does not resize the table, * check for comodification, etc. It calls createEntry rather than * addEntry. */ private void putForCreate(final K key, final V value) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); /** * Look for preexisting entry for key. This will never happen for * clone or de-serialize. It will only happen for construction if the * input Map is a sorted map whose ordering is inconsistent w/ equals. */ for (Entry<K, V> e = table[i]; e != null; e = e.next) { if (e.hash == hash && keyComparatorEq(k, e.key)) { e.value = value; return; } } createEntry(hash, k, value, i); }
/** * This method is used instead of put by constructors and * pseudoconstructors (clone, readObject). It does not resize the table, * check for comodification, etc. It calls createEntry rather than * addEntry. */ private void putForCreate(final K key, final V value) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); /** * Look for preexisting entry for key. This will never happen for * clone or de-serialize. It will only happen for construction if the * input Map is a sorted map whose ordering is inconsistent w/ equals. */ for (Entry<K, V> e = table[i]; e != null; e = e.next) { if (e.hash == hash && keyComparatorEq(k, e.key)) { e.value = value; return; } } createEntry(hash, k, value, i); }
/** * Removes and returns the entry associated with the specified key * in the HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> removeEntryForKey(final Object key) { final K k = (K) maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> prev = table[i]; Entry<K, V> e = prev; while (e != null) { final Entry<K, V> next = e.next; if (e.hash == hash && keyComparatorEq(k, e.key)) { modCount++; size--; if (prev == e) { table[i] = next; } else { prev.next = next; } e.recordRemoval(this); return e; } prev = e; e = next; } return e; }
/** * Removes and returns the entry associated with the specified key * in the HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> removeEntryForKey(final Object key) { final K k = (K) maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> prev = table[i]; Entry<K, V> e = prev; while (e != null) { final Entry<K, V> next = e.next; if (e.hash == hash && keyComparatorEq(k, e.key)) { modCount++; size--; if (prev == e) { table[i] = next; } else { prev.next = next; } e.recordRemoval(this); return e; } prev = e; e = next; } return e; }
/** * Associates the specified value with the specified key in this map. * If the map previously contained a mapping for this key, the old * value is replaced. * * @param key key with which the specified value is to be associated. * @param value value to be associated with the specified key. * @return previous value associated with specified key, or <tt>null</tt> * if there was no mapping for key. A <tt>null</tt> return can * also indicate that the HashMap previously associated * <tt>null</tt> with the specified key. */ @Override public V put(final K key, final V value) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); for (Entry<K, V> e = table[i]; e != null; e = e.next) { if (e.hash == hash && keyComparatorEq(k, e.key)) { final V oldValue = e.value; e.value = value; e.recordAccess(this); return oldValue; } } modCount++; addEntry(hash, k, value, i); return null; }
/** * Associates the specified value with the specified key in this map. * If the map previously contained a mapping for this key, the old * value is replaced. * * @param key key with which the specified value is to be associated. * @param value value to be associated with the specified key. * @return previous value associated with specified key, or <tt>null</tt> * if there was no mapping for key. A <tt>null</tt> return can * also indicate that the HashMap previously associated * <tt>null</tt> with the specified key. */ @Override public V put(final K key, final V value) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); for (Entry<K, V> e = table[i]; e != null; e = e.next) { if (e.hash == hash && keyComparatorEq(k, e.key)) { final V oldValue = e.value; e.value = value; e.recordAccess(this); return oldValue; } } modCount++; addEntry(hash, k, value, i); return null; }
/** * Returns the entry associated with the specified key in the * HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> getEntry(final K key) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null && !(e.hash == hash && keyComparatorEq(k, e.key))) { e = e.next; } return e; }
/** * Returns the entry associated with the specified key in the * HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> getEntry(final K key) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null && !(e.hash == hash && keyComparatorEq(k, e.key))) { e = e.next; } return e; }
/** * Returns the entry associated with the specified key in the * HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> getEntry(final K key) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null && !(e.hash == hash && keyComparatorEq(k, e.key))) { e = e.next; } return e; }
/** * Returns the entry associated with the specified key in the * HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> getEntry(final K key) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null && !(e.hash == hash && keyComparatorEq(k, e.key))) { e = e.next; } return e; }
/** * Returns the entry associated with the specified key in the * HashMap. Returns null if the HashMap contains no mapping * for this key. */ Entry<K, V> getEntry(final K key) { final K k = maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null && !(e.hash == hash && keyComparatorEq(k, e.key))) { e = e.next; } return e; }
/** * Returns <tt>true</tt> if this map contains a mapping for the * specified key. * * @param key The key whose presence in this map is to be tested * @return <tt>true</tt> if this map contains a mapping for the specified * key. */ @Override public boolean containsKey(final Object key) { final K k = (K) maskNull(key); final int hash = keyComparatorHash(k); final int i = indexFor(hash, table.length); Entry<K, V> e = table[i]; while (e != null) { if (e.hash == hash && keyComparatorEq(k, e.key)) { return true; } e = e.next; } return false; }