boolean equals(Map.Entry<K, V> e) { Object thisKey = get(); if (thisKey == null) { return false; } else if (thisKey == KeyFactory.NULL) { thisKey = null; } return (thisKey == e.getKey()) && (this.value == null ? e.getValue() == null : this.value.equals(e.getValue())); }
private void cleanup() { // Cleanup after cleared References. Entry[] tab = this.table; ReferenceQueue queue = this.queue; Reference ref; while ((ref = queue.poll()) != null) { // Since buckets are single-linked, traverse entire list and // cleanup all cleared references in it. int index = (((Entry) ref).hash & 0x7fffffff) % tab.length; for (Entry e = tab[index], prev = null; e != null; e = e.next) { if (e.get() == null) { this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } this.count--; } else { prev = e; } } } }
public boolean containsKey(Object key) { if (key == null) { key = KeyFactory.NULL; } Entry[] tab = this.table; int hash = System.identityHashCode(key); int index = (hash & 0x7fffffff) % tab.length; for (Entry e = tab[index], prev = null; e != null; e = e.next) { Object entryKey = e.get(); if (entryKey == null) { // Clean up after a cleared Reference. this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } this.count--; } else if (e.hash == hash && key == entryKey) { return true; } else { prev = e; } } return false; }
Object entryKey = e.get();
Object entryKey = e.get();
private void rehash() { int oldCapacity = this.table.length; Entry[] oldMap = this.table; int newCapacity = oldCapacity * 2 + 1; if (newCapacity <= 0) { // Overflow. if ((newCapacity = Integer.MAX_VALUE) == oldCapacity) { return; } } Entry[] newMap = new Entry[newCapacity]; this.modCount++; this.threshold = (int)(newCapacity * this.loadFactor); this.table = newMap; for (int i = oldCapacity ; i-- > 0 ;) { for (Entry old = oldMap[i] ; old != null ; ) { Entry e = old; old = old.next; // Only copy entry if its key hasn't been cleared. if (e.get() == null) { this.count--; } else { int index = (e.hash & 0x7fffffff) % newCapacity; e.next = newMap[index]; newMap[index] = e; } } } }
public boolean containsKey(Object key) { if (key == null) { key = KeyFactory.NULL; } Entry[] tab = this.table; int hash = System.identityHashCode(key); int index = (hash & 0x7fffffff) % tab.length; for (Entry e = tab[index], prev = null; e != null; e = e.next) { Object entryKey = e.get(); if (entryKey == null) { // Clean up after a cleared Reference. this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } this.count--; } else if (e.hash == hash && key == entryKey) { return true; } else { prev = e; } } return false; }
private void cleanup() { // Cleanup after cleared References. Entry[] tab = this.table; ReferenceQueue queue = this.queue; Reference ref; while ((ref = queue.poll()) != null) { // Since buckets are single-linked, traverse entire list and // cleanup all cleared references in it. int index = (((Entry) ref).hash & 0x7fffffff) % tab.length; for (Entry e = tab[index], prev = null; e != null; e = e.next) { if (e.get() == null) { this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } this.count--; } else { prev = e; } } } }
public V get(Object key) { if (key == null) { key = KeyFactory.NULL; } Entry<K, V>[] tab = this.table; int hash = System.identityHashCode(key); int index = (hash & 0x7fffffff) % tab.length; for (Entry<K, V> e = tab[index], prev = null; e != null; e = e.next) { Object entryKey = e.get(); if (entryKey == null) { // Clean up after a cleared Reference. this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } this.count--; } else if (e.hash == hash && key == entryKey) { return e.value; } else { prev = e; } } return null; }
public K getKey() { K key = Entry.this.get(); return key == KeyFactory.NULL ? null : key; }
protected Object copy(ReferenceQueue queue) { return new Entry(this.hash, get(), queue, this.value, (this.next == null ? null : (Entry)this.next.copy(queue))); } }
boolean equals(Map.Entry<K, V> e) { Object thisKey = get(); if (thisKey == null) { return false; } else if (thisKey == KeyFactory.NULL) { thisKey = null; } return (thisKey == e.getKey()) && (this.value == null ? e.getValue() == null : this.value.equals(e.getValue())); }
Object entryKey = e.get();
Object entryKey = e.get();
private void rehash() { int oldCapacity = this.table.length; Entry[] oldMap = this.table; int newCapacity = oldCapacity * 2 + 1; if (newCapacity <= 0) { // Overflow. if ((newCapacity = Integer.MAX_VALUE) == oldCapacity) { return; } } Entry[] newMap = new Entry[newCapacity]; this.modCount++; this.threshold = (int)(newCapacity * this.loadFactor); this.table = newMap; for (int i = oldCapacity ; i-- > 0 ;) { for (Entry old = oldMap[i] ; old != null ; ) { Entry e = old; old = old.next; // Only copy entry if its key hasn't been cleared. if (e.get() == null) { this.count--; } else { int index = (e.hash & 0x7fffffff) % newCapacity; e.next = newMap[index]; newMap[index] = e; } } } }
public V get(Object key) { if (key == null) { key = KeyFactory.NULL; } Entry<K, V>[] tab = this.table; int hash = System.identityHashCode(key); int index = (hash & 0x7fffffff) % tab.length; for (Entry<K, V> e = tab[index], prev = null; e != null; e = e.next) { Object entryKey = e.get(); if (entryKey == null) { // Clean up after a cleared Reference. this.modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } this.count--; } else if (e.hash == hash && key == entryKey) { return e.value; } else { prev = e; } } return null; }
public K getKey() { K key = Entry.this.get(); return key == KeyFactory.NULL ? null : key; }
protected Object copy(ReferenceQueue queue) { return new Entry(this.hash, get(), queue, this.value, (this.next == null ? null : (Entry)this.next.copy(queue))); } }