/** * @return the size of this <tt>IdentityWeakHashMap</tt>. */ public int size() { cleanUp(); return count; }
/** * @return the size of this <tt>IdentityWeakHashMap</tt>. */ public int size() { cleanUp(); return count; }
/** * @return the size of this <tt>IdentityWeakHashMap</tt>. */ public int size() { cleanUp(); return count; }
/** * Returns <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains a * mapping for the given key. Equality is tested by reference. * * @param key object to be used as a key into this * <tt>IdentityWeakHashMap</tt>. * @return <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains a * mapping for key. */ public boolean containsKey(Object key) { if (key == null) { throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); } cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) { if (e.key.get() == key) { return true; } } return false; }
/** * Returns <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains * the given object. Equality is tested by the equals() method. * * @param obj the object to find. * @return <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains * obj. * @throws <tt>NullPointerException</tt> if obj is null</tt>. */ public boolean containsValue(Object obj) { if (obj == null) { throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); } //cleanup before searching as to reduce number of possible empty Entries cleanUp(); WeakEntry<K,V>[] copyOfEntries = entries; for (int i = copyOfEntries.length; i-- > 0;) { for (WeakEntry<K,V> e = copyOfEntries[i]; e != null; e = e.next) { if (obj.equals(e.value.get())) { return true; } } } return false; }
/** * Returns <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains * the given object. Equality is tested by the equals() method. * * @param obj the object to find. * @return <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains * obj. * @throws <tt>NullPointerException</tt> if obj is null</tt>. */ public boolean containsValue(Object obj) { if (obj == null) { throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); } //cleanup before searching as to reduce number of possible empty Entries cleanUp(); WeakEntry<K,V>[] copyOfEntries = entries; for (int i = copyOfEntries.length; i-- > 0;) { for (WeakEntry<K,V> e = copyOfEntries[i]; e != null; e = e.next) { if (obj.equals(e.value.get())) { return true; } } } return false; }
/** * Returns the value to which the given key is mapped in this * <tt>IdentityWeakHashMap</tt>. Returns <tt>null</tt> if this * <tt>IdentityWeakHashMap</tt> contains no mapping for this key. * * @return the value to which this <tt>IdentityWeakHashMap</tt> maps the * given key. * @param key key whose associated value is to be returned. */ public V get(Object key) { if (key == null) return null; cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) { if (e.key.get() == key) { return (V)e.value.get(); } } return null; }
/** * Returns <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains a * mapping for the given key. Equality is tested by reference. * * @param key object to be used as a key into this * <tt>IdentityWeakHashMap</tt>. * @return <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains a * mapping for key. */ public boolean containsKey(Object key) { if (key == null) { throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); } cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) { if (e.key.get() == key) { return true; } } return false; }
/** * Returns the value to which the given key is mapped in this * <tt>IdentityWeakHashMap</tt>. Returns <tt>null</tt> if this * <tt>IdentityWeakHashMap</tt> contains no mapping for this key. * * @return the value to which this <tt>IdentityWeakHashMap</tt> maps the * given key. * @param key key whose associated value is to be returned. */ public V get(Object key) { if (key == null) return null; cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) { if (e.key.get() == key) { return (V)e.value.get(); } } return null; }
/** * Returns <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains a * mapping for the given key. Equality is tested by reference. * * @param key object to be used as a key into this * <tt>IdentityWeakHashMap</tt>. * @return <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains a * mapping for key. */ public boolean containsKey(Object key) { if (key == null) { throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); } cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) { if (e.key.get() == key) { return true; } } return false; }
/** * Returns <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains * the given object. Equality is tested by the equals() method. * * @param obj the object to find. * @return <tt>true</tt> if this <tt>IdentityWeakHashMap</tt> contains * obj. * @throws <tt>NullPointerException</tt> if obj is null</tt>. */ public boolean containsValue(Object obj) { if (obj == null) { throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); } //cleanup before searching as to reduce number of possible empty Entries cleanUp(); WeakEntry<K,V>[] copyOfEntries = entries; for (int i = copyOfEntries.length; i-- > 0;) { for (WeakEntry<K,V> e = copyOfEntries[i]; e != null; e = e.next) { if (obj.equals(e.value.get())) { return true; } } } return false; }
/** * Returns the value to which the given key is mapped in this * <tt>IdentityWeakHashMap</tt>. Returns <tt>null</tt> if this * <tt>IdentityWeakHashMap</tt> contains no mapping for this key. * * @return the value to which this <tt>IdentityWeakHashMap</tt> maps the * given key. * @param key key whose associated value is to be returned. */ public V get(Object key) { if (key == null) return null; cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index]; e != null; e = e.next) { if (e.key.get() == key) { return (V)e.value.get(); } } return null; }
/** * Removes the mapping (key and its corresponding value) from this * <tt>IdentityWeakHashMap</tt>, if present. * * @param key key whose mapping is to be removed from the map. * @return the previous object for key or <tt>null</tt> if this * <tt>IdentityWeakHashMap</tt> did not have one. */ public V remove(Object key) { if (key == null) return null; cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index], prev = null; e != null; prev = e, e = e.next) { if (e.key.get() == key) { if (prev != null) { prev.next = e.next; } else { copyOfEntries[index] = e.next; } count--; return (V)e.value.get(); } } return null; }
/** * Removes the mapping (key and its corresponding value) from this * <tt>IdentityWeakHashMap</tt>, if present. * * @param key key whose mapping is to be removed from the map. * @return the previous object for key or <tt>null</tt> if this * <tt>IdentityWeakHashMap</tt> did not have one. */ public V remove(Object key) { if (key == null) return null; cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index], prev = null; e != null; prev = e, e = e.next) { if (e.key.get() == key) { if (prev != null) { prev.next = e.next; } else { copyOfEntries[index] = e.next; } count--; return (V)e.value.get(); } } return null; }
/** * Removes the mapping (key and its corresponding value) from this * <tt>IdentityWeakHashMap</tt>, if present. * * @param key key whose mapping is to be removed from the map. * @return the previous object for key or <tt>null</tt> if this * <tt>IdentityWeakHashMap</tt> did not have one. */ public V remove(Object key) { if (key == null) return null; cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key); int index = (hash & 0x7FFFFFFF) % copyOfEntries.length; for (WeakEntry e = copyOfEntries[index], prev = null; e != null; prev = e, e = e.next) { if (e.key.get() == key) { if (prev != null) { prev.next = e.next; } else { copyOfEntries[index] = e.next; } count--; return (V)e.value.get(); } } return null; }
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key);
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key);
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("null_not_supported_identityweakhashmap")); cleanUp(); WeakEntry[] copyOfEntries = entries; int hash = System.identityHashCode(key);