本文整理汇总了Java中gnu.trove.TObjectHashingStrategy.IDENTITY属性的典型用法代码示例。如果您正苦于以下问题:Java TObjectHashingStrategy.IDENTITY属性的具体用法?Java TObjectHashingStrategy.IDENTITY怎么用?Java TObjectHashingStrategy.IDENTITY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gnu.trove.TObjectHashingStrategy
的用法示例。
在下文中一共展示了TObjectHashingStrategy.IDENTITY属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testKeysRemovedWhenIdentityStrategyIsUsed
@Test(timeout = TIMEOUT)
public void testKeysRemovedWhenIdentityStrategyIsUsed() {
@SuppressWarnings("unchecked") ConcurrentWeakHashMap<Object, Object> map = new ConcurrentWeakHashMap<Object, Object>(TObjectHashingStrategy.IDENTITY);
map.put(new Object(), new Object());
do {
tryGcSoftlyReachableObjects(); // sometimes weak references are not collected under linux, try to stress gc to force them
System.gc();
}
while (!map.processQueue());
map.put(this, this);
assertEquals(1, map.underlyingMapSize());
}
示例2: classify
@Override
public Iterable<LookupElement> classify(Iterable<LookupElement> source, final ProcessingContext context) {
checkPrefixChanged(context);
final Collection<List<LookupElement>> byWeight = buildMapByWeight(source, context).descendingMap().values();
List<LookupElement> initialList = getInitialNoStatElements(source, context);
//noinspection unchecked
final THashSet<LookupElement> initialSet = new THashSet<LookupElement>(initialList, TObjectHashingStrategy.IDENTITY);
final Condition<LookupElement> notInInitialList = new Condition<LookupElement>() {
@Override
public boolean value(LookupElement element) {
return !initialSet.contains(element);
}
};
return ContainerUtil.concat(initialList, new Iterable<LookupElement>() {
@Override
public Iterator<LookupElement> iterator() {
return new FlatteningIterator<List<LookupElement>, LookupElement>(byWeight.iterator()) {
@Override
protected Iterator<LookupElement> createValueIterator(List<LookupElement> group) {
return myNext.classify(ContainerUtil.findAll(group, notInInitialList), context).iterator();
}
};
}
});
}
示例3: testKeysRemovedWhenIdentityStrategyIsUsed
public void testKeysRemovedWhenIdentityStrategyIsUsed() {
ConcurrentWeakHashMap<Object, Object> map = new ConcurrentWeakHashMap<Object, Object>(TObjectHashingStrategy.IDENTITY);
map.put(new Object(), new Object());
do {
System.gc();
}
while (!map.processQueue());
map.put(this, this);
assertEquals(1, map.underlyingMapSize());
}
示例4: classify
@Override
public Iterable<LookupElement> classify(Iterable<LookupElement> source, final ProcessingContext context) {
checkPrefixChanged(context);
final Collection<List<LookupElement>> byWeight = buildMapByWeight(source).descendingMap().values();
List<LookupElement> initialList = getInitialNoStatElements(source, context);
//noinspection unchecked
final THashSet<LookupElement> initialSet = new THashSet<LookupElement>(initialList, TObjectHashingStrategy.IDENTITY);
final Condition<LookupElement> notInInitialList = new Condition<LookupElement>() {
@Override
public boolean value(LookupElement element) {
return !initialSet.contains(element);
}
};
return ContainerUtil.concat(initialList, new Iterable<LookupElement>() {
@Override
public Iterator<LookupElement> iterator() {
return new FlatteningIterator<List<LookupElement>, LookupElement>(byWeight.iterator()) {
@Override
protected Iterator<LookupElement> createValueIterator(List<LookupElement> group) {
return myNext.classify(ContainerUtil.findAll(group, notInInitialList), context).iterator();
}
};
}
});
}
示例5: identityStrategy
@SuppressWarnings("unchecked")
@NotNull
@Contract(pure=true)
public static <T> TObjectHashingStrategy<T> identityStrategy() {
return TObjectHashingStrategy.IDENTITY;
}