A map where keys are compared using identity comparison (like IdentityHashMap) but where the presence of an object as a key in the map does not prevent it being garbage collected (like WeakHashMap). This class does not implement the Map interface because it is difficult to ensure correct semantics for iterators over the entrySet().
Because we do not implement Map, we do not copy the questionable interface where you can call get(k) or remove(k) for any type of k, which of course can only have an effect if k is of type K.
This map does not support null keys.
| Modifier and Type | Class and Description |
|---|---|
| private static class | WeakIdentityHashMap.
WeakReference where equals and hashCode are based on the referent. |
| Modifier and Type | Field and Description |
|---|---|
| private Map | |
| private ReferenceQueue |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| pack-priv V | |
| pack-priv static <K, V> WeakIdentityHashMap | |
| private WeakReference | |
| private WeakReference | |
| public V | |
| public V |
| map | back to summary |
|---|---|
| private Map<WeakReference<K>, V> map | |
| refQueue | back to summary |
|---|---|
| private ReferenceQueue<K> refQueue | |
| WeakIdentityHashMap | back to summary |
|---|---|
| private WeakIdentityHashMap() | |
| expunge | back to summary |
|---|---|
| private void expunge() | |
| get | back to summary |
|---|---|
| pack-priv V get(K key) | |
| make | back to summary |
|---|---|
| pack-priv static <K, V> WeakIdentityHashMap | |
| makeReference | back to summary |
|---|---|
| private WeakReference | |
| makeReference | back to summary |
|---|---|
| private WeakReference | |
| put | back to summary |
|---|---|
| public V put(K key, V value) | |
| remove | back to summary |
|---|---|
| public V remove(K key) | |
| Modifier and Type | Field and Description |
|---|---|
| private final int |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public int |
| hashCode | back to summary |
|---|---|
| private final int hashCode | |
| IdentityWeakReference | back to summary |
|---|---|
| pack-priv IdentityWeakReference(T o) | |
| IdentityWeakReference | back to summary |
|---|---|
| pack-priv IdentityWeakReference(T o, ReferenceQueue<T> q) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |