boolean equals(Map.Entry e) { Object thisValue = get(); if (thisValue == null) { return false; } else if (thisValue == KeyFactory.NULL) { thisValue = null; } return (this.key == null ? e.getKey() == null : this.key.equals(e.getKey())) && (thisValue == null ? e.getValue() == null : thisValue.equals(e.getValue())); }
public int hashCode() { return this.hash ^ get().hashCode(); }
public boolean containsValue(Object value) { if (value == null) { value = KeyFactory.NULL; } Entry[] tab = this.table; for (int i = tab.length ; i-- > 0 ;) { for (Entry e = tab[i], prev = null; e != null; e = e.next) { Object entryValue = e.get(); if (entryValue == null) { // Clean up after a cleared Reference. this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[i] = e.next; } this.count--; } else if (value.equals(entryValue)) { return true; } else { prev = e; } } } return false; }
/** * Rehashes the contents of this map into a new <tt>HashMap</tt> instance * with a larger capacity. This method is called automatically when the * number of keys in this map exceeds its capacity and load factor. */ private void rehash() { int oldCapacity = this.table.length; Entry<K, V>[] oldMap = this.table; int newCapacity = oldCapacity * 2 + 1; Entry<K, V>[] newMap = new Entry[newCapacity]; this.modCount++; this.threshold = (int)(newCapacity * this.loadFactor); this.table = newMap; for (int i = oldCapacity ; i-- > 0 ;) { for (Entry<K, V> old = oldMap[i] ; old != null ; ) { Entry<K, V> e = old; old = old.next; // Only copy entry if its value hasn't been cleared. if (e.get() == null) { this.count--; } else { int index = (e.hash & 0x7fffffff) % newCapacity; e.next = newMap[index]; newMap[index] = e; } } } }
/** * Scans the contents of this map, removing all entries that have a * cleared soft value. */ private void cleanup() { Entry<K, V>[] tab = this.table; for (int i = tab.length ; i-- > 0 ;) { for (Entry<K, V> e = tab[i], prev = null; e != null; e = e.next) { if (e.get() == null) { // Clean up after a cleared Reference. this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[i] = e.next; } this.count--; } else { prev = e; } } } }
public boolean containsValue(Object value) { if (value == null) { value = KeyFactory.NULL; } Entry[] tab = this.table; for (int i = tab.length ; i-- > 0 ;) { for (Entry e = tab[i], prev = null; e != null; e = e.next) { Object entryValue = e.get(); if (entryValue == null) { // Clean up after a cleared Reference. this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[i] = e.next; } this.count--; } else if (value.equals(entryValue)) { return true; } else { prev = e; } } } return false; }
public int hashCode() { return this.hash ^ get().hashCode(); }
boolean equals(Map.Entry e) { Object thisValue = get(); if (thisValue == null) { return false; } else if (thisValue == KeyFactory.NULL) { thisValue = null; } return (this.key == null ? e.getKey() == null : this.key.equals(e.getKey())) && (thisValue == null ? e.getValue() == null : thisValue.equals(e.getValue())); }
/** * Rehashes the contents of this map into a new <tt>HashMap</tt> instance * with a larger capacity. This method is called automatically when the * number of keys in this map exceeds its capacity and load factor. */ private void rehash() { int oldCapacity = this.table.length; Entry<K, V>[] oldMap = this.table; int newCapacity = oldCapacity * 2 + 1; Entry<K, V>[] newMap = new Entry[newCapacity]; this.modCount++; this.threshold = (int)(newCapacity * this.loadFactor); this.table = newMap; for (int i = oldCapacity ; i-- > 0 ;) { for (Entry<K, V> old = oldMap[i] ; old != null ; ) { Entry<K, V> e = old; old = old.next; // Only copy entry if its value hasn't been cleared. if (e.get() == null) { this.count--; } else { int index = (e.hash & 0x7fffffff) % newCapacity; e.next = newMap[index]; newMap[index] = e; } } } }
/** * Scans the contents of this map, removing all entries that have a * cleared soft value. */ private void cleanup() { Entry<K, V>[] tab = this.table; for (int i = tab.length ; i-- > 0 ;) { for (Entry<K, V> e = tab[i], prev = null; e != null; e = e.next) { if (e.get() == null) { // Clean up after a cleared Reference. this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[i] = e.next; } this.count--; } else { prev = e; } } } }