| java.lang.Object |
| ↳ |
java.lang.ref.ReferenceQueue<T> |
| |
↳ |
com.pnfsoftware.jeb.util.concurrent.WeakConcurrentMap<K, V> |
Known Direct Subclasses
|
Class Overview
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 does not implement the java.util.Map 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.
Summary
| Fields |
|
public
final
ConcurrentMap<IWeakKey<K>, V> |
target |
|
| Protected Methods |
|
V
|
defaultValue(K key)
Creates a default value.
|
|
[Expand]
Inherited Methods |
From class
java.lang.ref.ReferenceQueue
|
Reference<? extends T>
|
poll()
|
|
Reference<? extends T>
|
remove(long arg0)
|
|
Reference<? extends T>
|
remove()
|
|
From class
java.lang.Object
|
Object
|
clone()
|
|
boolean
|
equals(Object arg0)
|
|
void
|
finalize()
|
|
final
Class<?>
|
getClass()
|
|
int
|
hashCode()
|
|
final
void
|
notify()
|
|
final
void
|
notifyAll()
|
|
String
|
toString()
|
|
final
void
|
wait(long arg0, int arg1)
|
|
final
void
|
wait(long arg0)
|
|
final
void
|
wait()
|
|
From interface
java.lang.Iterable
|
abstract
void
|
forEach(Consumer<? super T> arg0)
|
|
abstract
Iterator<T>
|
iterator()
|
|
abstract
Spliterator<T>
|
spliterator()
|
|
From interface
java.lang.Runnable
|
Fields
public
final
ConcurrentMap<IWeakKey<K>, V>
target
Public Constructors
public
WeakConcurrentMap
(boolean cleanerThread)
Parameters
| cleanerThread |
true if a thread should be started that removes stale entries.
|
Public Methods
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.
Returns
- The minimum size of this map.
public
boolean
containsKey
(K key)
Parameters
| key |
The key of the entry. |
Returns
true if the key already defines a value.
public
void
expungeStaleEntries
()
Cleans all unused references.
public
V
get
(K key)
Parameters
| key |
The key of the entry. |
Returns
- The value of the entry or the default value if it did not exist.
public
Thread
getCleanerThread
()
Returns
- The cleaner thread or
null if no such thread was set.
public
Iterator<Entry<K, V>>
iterator
()
public
V
put
(K key, V value)
Parameters
| key |
The key of the entry. |
| value |
The value of the entry. |
Returns
- The previous entry or
null if it does not exist.
public
V
remove
(K key)
Parameters
| key |
The key of the entry. |
Returns
- The removed entry or
null if it does not exist.
Protected Methods
protected
V
defaultValue
(K key)
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.
Parameters
| key |
The key for which to create a default value. |
Returns
- The default value for a key without value or
null for not defining a default
value.