# Class: com.pnfsoftware.jeb.util.collect.WeakIdentityHashMap

A pseudo map where keys are compared using identity comparison \(like [IdentityHashMap](IdentityHashMap)\) but where the presence of an object as a key in the map does not prevent it being garbage collected \(like [WeakHashMap](WeakHashMap)\). This class does not implement the [Map](Map) interface because it is difficult to ensure correct semantics for iterators over the entrySet\(\). This map does not support null keys. 

 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. 

 Implementation note: The approach is to wrap each key in a WeakReference and use the wrapped value as a key in an ordinary HashMap. The WeakReference has to be a subclass IdentityWeakReference \(IWR\) where two IWRs are equal if they refer to the same object. This enables us to find the entry again. 

 Forked from https://android.googlesource.com/platform/libcore/\+/42cdd0bf7251074df8bf6dfa7f5d62a01c0a1ef6/ojluni/src/main/java/com/sun/jmx/mbeanserver/WeakIdentityHashMap.java

## Constructor: WeakIdentityHashMap
- parameter: `initialCapacity`, type: `int`
- parameter: `loadFactor`, type: `float`

Description: Create a weak identity hash map.
parameter: initialCapacity: initial capacity
parameter: loadFactor: load factor

## Constructor: WeakIdentityHashMap
- parameter: `initialCapacity`, type: `int`

Description: Create a weak identity hash map.
parameter: initialCapacity: initial capacity

## Constructor: WeakIdentityHashMap

Description: Create a weak identity hash map.

## Method: clear

Description: Remove all mappings.

## Method: entrySet
- return type: `java.util.Set<java.util.Map.Entry<K,V>>`

Description: Retrieve live entries.
return: copy of the live entry set

## Method: expunge

Description: Remove entries whose weak keys were collected.

## Method: get
- parameter: `key`, type: `K`
- return type: `V`

Description: Retrieve a value.
parameter: key: key compared by identity
return: mapped value, or null

## Method: isEmpty
- return type: `boolean`

Description: 
return: true if no live entry exists

## Method: keySet
- return type: `java.util.Set<K>`

Description: Retrieve live keys.
return: copy of the live key set

## Method: put
- parameter: `key`, type: `K`
- parameter: `value`, type: `V`
- return type: `V`

Description: Add or replace a mapping.
parameter: key: non\-null key compared by identity
parameter: value: value
return: previous value, or null

## Method: putUnsafe
- parameter: `key`, type: `K`
- parameter: `value`, type: `V`
- return type: `V`

Description: Add or replace a mapping without rejecting null keys.
parameter: key: key compared by identity
parameter: value: value
return: previous value, or null

## Method: remove
- parameter: `key`, type: `K`
- return type: `V`

Description: Remove a mapping.
parameter: key: key compared by identity
return: removed value, or null

## Method: size
- return type: `int`

Description: 
return: number of live entries

## Method: toString
- return type: `java.lang.String`


## Method: values
- return type: `java.util.Collection<V>`

Description: Retrieve values.
return: collection of values

