com.softicar.platform.common.container.map.weak.identity.WeakIdentityHashMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.container.map.weak.identity;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.function.Supplier;
/**
* This map combines the features of {@link IdentityHashMap} and
* {@link WeakHashMap}.
*
* The keys of this map are hashed by identity and referenced by weak
* references.
*
* This map supports null for values but not for keys.
*
* @see IdentityHashMap
* @see WeakHashMap
* @author Oliver Richers
*/
public class WeakIdentityHashMap {
private final Map, V> hashMap;
private final ReferenceQueue referenceQueue;
public WeakIdentityHashMap() {
this(HashMap::new);
}
public WeakIdentityHashMap(Supplier