本文整理匯總了Java中java.lang.ref.Reference.hashCode方法的典型用法代碼示例。如果您正苦於以下問題:Java Reference.hashCode方法的具體用法?Java Reference.hashCode怎麽用?Java Reference.hashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.ref.Reference
的用法示例。
在下文中一共展示了Reference.hashCode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: purge
import java.lang.ref.Reference; //導入方法依賴的package包/類
/**
* Purges the specified reference.
*
* @param ref the reference to purge
*/
protected void purge(Reference ref) {
// The hashCode of the reference is the hashCode of the
// mapping key, even if the reference refers to the
// mapping value...
int hash = ref.hashCode();
int index = hashIndex(hash, data.length);
HashEntry previous = null;
HashEntry entry = data[index];
while (entry != null) {
if (((ReferenceEntry) entry).purge(ref)) {
if (previous == null) {
data[index] = entry.next;
} else {
previous.next = entry.next;
}
this.size--;
return;
}
previous = entry;
entry = entry.next;
}
}
示例2: purge
import java.lang.ref.Reference; //導入方法依賴的package包/類
/**
* Purges the specified reference.
*
* @param ref the reference to purge
*/
protected void purge(final Reference<?> ref) {
// The hashCode of the reference is the hashCode of the
// mapping key, even if the reference refers to the
// mapping value...
final int hash = ref.hashCode();
final int index = hashIndex(hash, data.length);
HashEntry<K, V> previous = null;
HashEntry<K, V> entry = data[index];
while (entry != null) {
if (((ReferenceEntry<K, V>) entry).purge(ref)) {
if (previous == null) {
data[index] = entry.next;
} else {
previous.next = entry.next;
}
this.size--;
return;
}
previous = entry;
entry = entry.next;
}
}