@FunctionalInterface public static interface IndexerFunction.IdentityKey<K,V> extends IndexerFunction<K,V>
IndexerFunction
that distinguishes and identifies elements using identity comparison of object keys.
It uses System.identityHashCode(Object)
method instead of
Object.hashCode()
method to compute hashcode and reference comparison
instead of Object.equals(Object)
method to determine identity.
In order to use this functional interface, cast a lambda expression to it when creating IndexedSet
. For example,
IndexedSet<Key, Value> set = IndexedSet.
create
((IndexerFunction.IdentityKey<Key, Value>)Value::getKey);
IndexerFunction.DefaultIdentityKey, IndexerFunction.DefaultIndexerFunction, IndexerFunction.IdentityKey<K,V>, IndexerFunction.IntKey<V>, IndexerFunction.LongKey<V>
DEFAULT, DEFAULT_IDENTITY_KEY
Modifier and Type | Method and Description |
---|---|
default int |
hashCodeByKey(K key)
Returns hash code for specified object key; called when performing operations using object keys.
|
default boolean |
matchesByKey(K key,
V value)
Determines if specified object key matches specified value; called when performing operations using object keys.
|
getNumberKey, getObjectKey, hashCodeByKey, hashCodeByValue, matchesByKey, matchesByValue
default int hashCodeByKey(K key)
This implementation delegates to
System.
expression.identityHashCode
(key)
hashCodeByKey
in interface IndexerFunction<K,V>
default boolean matchesByKey(K key, V value)
This implementation delegates to
(key ==
expression.getObjectKey
(value))
matchesByKey
in interface IndexerFunction<K,V>
Copyright © 2002–2025 Devexperts LLC. All rights reserved.