|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
K - the type of keys to be stored in the returned mapV - the type of values to be stored in the returned mapE - internal entry type, not directly exposed to clients in map
viewspublic static interface CustomConcurrentHashMap.Strategy<K,V,E>
Implements behavior specific to the client's concurrent hash map implementation. Used by the framework to create new entries and perform operations on them.
Method parameters are never null unless otherwise specified.
This class does not allow null to be used as a key.
Setting values to null is not permitted, but entries may have null keys
or values for various reasons. For example, the key or value may have
been garbage collected or reclaimed through other means.
CustomConcurrentHashMap treats entries with null keys and values as
"partially reclaimed" and ignores them for the most part. Entries may
enter a partially reclaimed state but they must not leave it. Partially
reclaimed entries will not be copied over during table expansions, for
example. Strategy implementations should proactively remove partially
reclaimed entries so that Map.isEmpty() and Map.size()
return up-to-date results.
| Method Summary | |
|---|---|
E |
copyEntry(K key,
E original,
E newNext)
Creates a copy of the given entry pointing to the given next entry. |
boolean |
equalKeys(K a,
java.lang.Object b)
Returns true if the two given keys are equal, false otherwise. |
boolean |
equalValues(V a,
java.lang.Object b)
Returns true if the two given values are equal, false otherwise. |
int |
getHash(E entry)
Returns the hash code that was passed to newEntry(K, int, E))
when the given entry was created. |
K |
getKey(E entry)
Gets the key for the given entry. |
E |
getNext(E entry)
Gets the next entry relative to the given entry, the exact same entry that was provided to newEntry(K, int, E) when the given entry was
created. |
V |
getValue(E entry)
Gets the value of an entry using volatile semantics. |
int |
hashKey(java.lang.Object key)
Returns a hash code for the given key. |
E |
newEntry(K key,
int hash,
E next)
Constructs a new entry for the given key with a pointer to the given next entry. |
void |
setInternals(CustomConcurrentHashMap.Internals<K,V,E> internals)
Provides an API for interacting directly with the map's internal entries to this strategy. |
void |
setValue(E entry,
V value)
Sets the value of an entry using volatile semantics. |
| Method Detail |
|---|
E newEntry(K key,
int hash,
E next)
This method may return different entry implementations depending upon whether next is null or not. For example, if next is null (as will often be the case), this factory might use an entry class that doesn't waste memory on an unnecessary field.
key - for this entryhash - of key returned by hashKey(java.lang.Object)next - entry (used when implementing a hash bucket as a linked
list, for example), possibly null
E copyEntry(K key,
E original,
E newNext)
original to the returned entry. For example,
CustomConcurrentHashMap might use this method when removing other
entries or expanding the internal table.
key - for original as well as the returned entry.
Explicitly provided here to prevent reclamation of the key at an
inopportune time in implementations that don't otherwise keep
a strong reference to the key.original - entry from which the value and other
implementation-specific state should be copiednewNext - the next entry the new entry should point to, possibly
null
void setValue(E entry,
V value)
entry - to set the value onvalue - to setV getValue(E entry)
entry - to get the value from
boolean equalKeys(K a,
java.lang.Object b)
a - key from inside the mapb - key passed from caller, not necesarily of type Kthe same contractual obligations apply here
boolean equalValues(V a,
java.lang.Object b)
a - value from inside the mapb - value passed from caller, not necesarily of type Vthe same contractual obligations apply hereint hashKey(java.lang.Object key)
the same contractual obligations apply hereK getKey(E entry)
entry - to get key from
E getNext(E entry)
newEntry(K, int, E) when the given entry was
created.
newEntry(K, int, E)int getHash(E entry)
newEntry(K, int, E))
when the given entry was created.
void setInternals(CustomConcurrentHashMap.Internals<K,V,E> internals)
internals - of the map, enables direct interaction with the
internal entries
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||