java.lang.Object
java.lang.ref.ReferenceQueue<K>
com.tlcsdm.core.concurrent.AbstractWeakConcurrentMap<K,V,L>
- 直接已知子类:
WeakConcurrentMap
public abstract class AbstractWeakConcurrentMap<K,V,L>
extends ReferenceQueue<K>
implements Runnable, Iterable<Map.Entry<K,V>>
A thread-safe map with weak keys. Entries are based on a key's system hash code and keys are considered equal only by reference equality. This class offers an abstract-base implementation that allows to override methods.
This class does not implement theMap interface because this implementation is incompatible
with the map contract. While iterating over a map's entries, any key that has not passed iteration is referenced non-weakly.- 作者:
- unknowIfGuestInDream
-
嵌套类概要
嵌套类修饰符和类型类说明private classprivate classstatic final class -
字段概要
字段 -
构造器概要
构造器限定符构造器说明protectedprotected -
方法概要
修饰符和类型方法说明intReturns the approximate size of this map where the returned number is at least as big as the actual number of entries.voidclear()Clears the entire map.booleancontainsKey(K key) protected VdefaultValue(K key) Creates a default value.voidCleans all unused references.getIfPresent(K key) protected abstract LgetLookupKey(K key) Override with care as it can cause lookup failures if done incorrectly.iterator()putIfAbsent(K key, V value) putIfProbablyAbsent(K key, V value) protected abstract voidresetLookupKey(L lookupKey) Resets any reusable state in the lookup key.voidrun()toString()从类继承的方法 java.lang.ref.ReferenceQueue
poll, remove, remove从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 java.lang.Iterable
forEach, spliterator
-
字段详细资料
-
target
-
-
构造器详细资料
-
AbstractWeakConcurrentMap
protected AbstractWeakConcurrentMap() -
AbstractWeakConcurrentMap
- 参数:
target- ConcurrentMap implementation that this class wraps.
-
-
方法详细资料
-
getLookupKey
Override with care as it can cause lookup failures if done incorrectly. The result must have the sameObject.hashCode()as the input and beequal toa weak reference of the key. When overriding this, also overrideresetLookupKey(L). -
resetLookupKey
Resets any reusable state in the lookup key. -
get
- 参数:
key- The key of the entry.- 返回:
- The value of the entry or the default value if it did not exist.
-
getIfPresent
- 参数:
key- The key of the entry.- 返回:
- The value of the entry or null if it did not exist.
-
containsKey
- 参数:
key- The key of the entry.- 返回:
trueif the key already defines a value.
-
put
- 参数:
key- The key of the entry.value- The value of the entry.- 返回:
- The previous entry or
nullif it does not exist.
-
putIfAbsent
- 参数:
key- The key of the entry.value- The value of the entry.- 返回:
- The previous entry or
nullif it does not exist.
-
putIfProbablyAbsent
- 参数:
key- The key of the entry.value- The value of the entry.- 返回:
- The previous entry or
nullif it does not exist.
-
remove
- 参数:
key- The key of the entry.- 返回:
- The removed entry or
nullif it does not exist.
-
clear
public void clear()Clears the entire map. -
defaultValue
Creates a default value. There is no guarantee that the requested value will be set as a once it is created in case that another thread requests a value for a key concurrently.- 参数:
key- The key for which to create a default value.- 返回:
- The default value for a key without value or
nullfor not defining a default value.
-
expungeStaleEntries
public void expungeStaleEntries()Cleans all unused references. -
approximateSize
public int approximateSize()Returns the approximate size of this map where the returned number is at least as big as the actual number of entries.- 返回:
- The minimum size of this map.
-
run
public void run() -
iterator
-
toString
-