|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.ref.Reference<T>
java.lang.ref.WeakReference<K>
org.semanticweb.elk.util.collections.entryset.WeakKeyEntry<K,T>
K - the type of the keys of the recordT - the type of the next element the record is connected withpublic abstract class WeakKeyEntry<K,T>
A prototype class for entries with weak keys, which can be collected by the garbage collector. Sub-classes should implement the method for computing the equality function for the entry and hash code of the keys, which will be used for initializing the hash code of the entry. The hashCode and equals methods should be compatible as usual. Note that the keys are mutable because they may become null at some later time. Thus, special care needs to be taken when implementing and using the equals method: it might be the case that the result of equality changes over time. For example, it would be unsafe to define two entries equal if both of them have null keys, since they might have been initialized with different hash values, and equals would be not compatible with the hash code. The hash code function does not have such a side effect
| Field Summary | |
|---|---|
protected int |
hash
The value used as a hash code of this record |
protected KeyEntry<T,? extends T> |
next
The reference to the next element |
| Constructor Summary | |
|---|---|
WeakKeyEntry(K key)
Create a weak record for the key |
|
| Method Summary | |
|---|---|
abstract int |
computeHashCode()
Compute the value which will be used as a final hash code for this object. |
abstract boolean |
equals(Object object)
|
K |
getKey()
|
KeyEntry<T,? extends T> |
getNext()
Returns the next next element of the entry, or null if there is no next element |
int |
hashCode()
|
void |
setNext(KeyEntry<T,? extends T> next)
Setting the input element as the next element of the entry. |
| Methods inherited from class java.lang.ref.Reference |
|---|
clear, enqueue, get, isEnqueued |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final int hash
protected KeyEntry<T,? extends T> next
| Constructor Detail |
|---|
public WeakKeyEntry(K key)
key - the key for which the weak record is created| Method Detail |
|---|
public K getKey()
getKey in interface KeyEntry<T,K>public void setNext(KeyEntry<T,? extends T> next)
next - the object that should be set as the next element of the
recordpublic KeyEntry<T,? extends T> getNext()
public int hashCode()
hashCode in class Objectpublic abstract int computeHashCode()
equals(Object) method usual.
public abstract boolean equals(Object object)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||