|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.devexperts.util.Indexer<Long,V>
com.devexperts.util.NumberKeyIndexer<V>
public abstract class NumberKeyIndexer<V>
A subclass of Indexer
that distinguishes and identifies elements using number keys.
It assumes that elements are fully identifiable by numeric ID and treats object keys as a mere wrappers. The hash function is computed using (int)(key ^ (key >>> 32)) formula.
The NumberKeyIndexer itself is not serializable. However, concrete subclasses shall be serializable in order to support serialization of indexed set and map.
Field Summary |
---|
Fields inherited from class com.devexperts.util.Indexer |
---|
DEFAULT |
Constructor Summary | |
---|---|
protected |
NumberKeyIndexer()
Sole constructor; for invocation by subclass constructors, typically implicit. |
Method Summary | |
---|---|
abstract long |
getNumberKey(V value)
Returns number key for specified value to be used for hashing and identification; called when explicit number key is needed or when other methods delegate operations as specified. |
Long |
getObjectKey(V value)
Returns object key for specified value to be used for hashing and identification; called when explicit object key is needed or when other methods delegate operations as specified. |
int |
hashCodeByKey(long key)
Returns hash code for specified number key; called when performing operations using number keys. |
int |
hashCodeByKey(Long key)
Returns hash code for specified object key; called when performing operations using object keys. |
int |
hashCodeByValue(V value)
Returns hash code for specified value; called when performing value-based operations, including rehash. |
boolean |
matchesByKey(long key,
V value)
Determines if specified number key matches specified value; called when performing operations using number keys. |
boolean |
matchesByKey(Long key,
V value)
Determines if specified object key matches specified value; called when performing operations using object keys. |
boolean |
matchesByValue(V new_value,
V old_value)
Determines if specified new value matches specified old value; called when performing value-based operations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected NumberKeyIndexer()
This implementation does nothing.
Method Detail |
---|
public int hashCodeByValue(V value)
This implementation computes hash function of getNumberKey(value)
expression.
hashCodeByValue
in class Indexer<Long,V>
public boolean matchesByValue(V new_value, V old_value)
This implementation delegates to (getNumberKey(new_value)
== getNumberKey(old_value)
) expression.
matchesByValue
in class Indexer<Long,V>
public Long getObjectKey(V value)
This implementation delegates to new Long(
getNumberKey(value))
expression.
getObjectKey
in class Indexer<Long,V>
UnsupportedOperationException
- if this strategy does not support object keys.public int hashCodeByKey(Long key)
This implementation computes hash function of ((Number)key).longValue()
expression.
hashCodeByKey
in class Indexer<Long,V>
UnsupportedOperationException
- if this strategy does not support object keys.public boolean matchesByKey(Long key, V value)
This implementation delegates to (((Number)key).longValue()
== getNumberKey(value)
) expression.
matchesByKey
in class Indexer<Long,V>
UnsupportedOperationException
- if this strategy does not support object keys.public abstract long getNumberKey(V value)
getNumberKey
in class Indexer<Long,V>
UnsupportedOperationException
- if this strategy does not support number keys.public int hashCodeByKey(long key)
This implementation computes hash function for specified key.
hashCodeByKey
in class Indexer<Long,V>
UnsupportedOperationException
- if this strategy does not support number keys.public boolean matchesByKey(long key, V value)
This implementation delegates to (key == getNumberKey(value)
) expression.
matchesByKey
in class Indexer<Long,V>
UnsupportedOperationException
- if this strategy does not support number keys.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |