本文整理汇总了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;
}
}