本文整理汇总了Java中gnu.trove.TObjectHashingStrategy类的典型用法代码示例。如果您正苦于以下问题:Java TObjectHashingStrategy类的具体用法?Java TObjectHashingStrategy怎么用?Java TObjectHashingStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TObjectHashingStrategy类属于gnu.trove包,在下文中一共展示了TObjectHashingStrategy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: factorDuplicates
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public static <D extends PsiElement> Map<D, List<D>> factorDuplicates(D[] elements, TObjectHashingStrategy<D> strategy) {
if (elements == null || elements.length == 0) return Collections.emptyMap();
THashMap<D, List<D>> map = new THashMap<D, List<D>>(strategy);
for (D element : elements) {
List<D> list = map.get(element);
if (list == null) {
list = new ArrayList<D>();
}
list.add(element);
map.put(element, list);
}
return map;
}
示例2: isModified
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public boolean isModified() {
List<Compiler> selectedElements = myValidators.getMarkedElements();
List<Compiler> markedValidators = getMarkedValidators();
if (markedValidators.size() != selectedElements.size()) {
return true;
}
Set<Compiler> set = new THashSet<Compiler>(selectedElements, new TObjectHashingStrategy<Compiler>() {
public int computeHashCode(Compiler object) {
return object.getDescription().hashCode();
}
public boolean equals(Compiler o1, Compiler o2) {
return o1.getDescription().equals(o2.getDescription());
}
});
return myConfiguration.VALIDATE_ON_BUILD != myValidateBox.isSelected() ||
set.retainAll(markedValidators) ||
myExcludedConfigurable.isModified();
}
示例3: createSet
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
@Nonnull
public static <K, V> MultiMap<K, V> createSet(final TObjectHashingStrategy strategy) {
return new MultiMap<K, V>() {
@Nonnull
@Override
protected Collection<V> createCollection() {
return new SmartHashSet<V>();
}
@Nonnull
@Override
protected Collection<V> createEmptyCollection() {
return Collections.emptySet();
}
@Nonnull
@Override
protected Map<K, Collection<V>> createMap() {
return new THashMap<K, Collection<V>>(strategy);
}
};
}
示例4: addAdoptedName
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
void addAdoptedName(String name, boolean caseSensitive) {
if (myAdoptedNames == null) {
//noinspection unchecked
myAdoptedNames = new THashSet<String>(0, caseSensitive ? TObjectHashingStrategy.CANONICAL : CaseInsensitiveStringHashingStrategy.INSTANCE);
}
myAdoptedNames.add(name);
}
示例5: testKeysRemovedWhenIdentityStrategyIsUsed
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
@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());
}
示例6: create
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
@NotNull
public static <K, V> MultiMap<K, V> create(@NotNull final TObjectHashingStrategy<K> strategy) {
return new MultiMap<K, V>() {
@NotNull
@Override
protected Map<K, Collection<V>> createMap() {
return new THashMap<K, Collection<V>>(strategy);
}
};
}
示例7: ConcurrentWeakKeySoftValueHashMap
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public ConcurrentWeakKeySoftValueHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel,
@NotNull final TObjectHashingStrategy<K> hashingStrategy) {
myHashingStrategy = hashingStrategy;
myMap = ContainerUtil.newConcurrentMap(initialCapacity, loadFactor, concurrencyLevel, ContainerUtil.<KeyReference<K,V>>canonicalStrategy());
}
示例8: WeakKey
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
WeakKey(@NotNull K k,
@NotNull ValueReference<K, V> valueReference,
@NotNull TObjectHashingStrategy<K> strategy,
@NotNull ReferenceQueue<K> queue) {
super(k, queue);
myValueReference = valueReference;
myHash = strategy.computeHashCode(k);
myStrategy = strategy;
}
示例9: ConcurrentRefHashMap
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public ConcurrentRefHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel,
@NotNull TObjectHashingStrategy<K> hashingStrategy) {
myHashingStrategy = hashingStrategy == THIS ? this : hashingStrategy;
myMap = ContainerUtil.<KeyReference<K, V>, V>newConcurrentMap(initialCapacity, loadFactor, concurrencyLevel, CANONICAL);
}
示例10: RefHashMap
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public RefHashMap(@NotNull final TObjectHashingStrategy<K> hashingStrategy) {
this(4, 0.8f, new TObjectHashingStrategy<Key<K>>() {
@Override
public int computeHashCode(final Key<K> object) {
return hashingStrategy.computeHashCode(object.get());
}
@Override
public boolean equals(final Key<K> o1, final Key<K> o2) {
return hashingStrategy.equals(o1.get(), o2.get());
}
});
}
示例11: Node
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
Node(int hash, K key, V val, Node<K, V> next, @NotNull TObjectHashingStrategy<K> hashingStrategy) {
this.hash = hash;
this.key = key;
this.val = val;
this.next = next;
myHashingStrategy = hashingStrategy;
}
示例12: ConcurrentHashMap
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public ConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel, @NotNull TObjectHashingStrategy<K> hashingStrategy) {
if (!(loadFactor > 0.0f) || initialCapacity < 0 || concurrencyLevel <= 0) {
throw new IllegalArgumentException();
}
if (initialCapacity < concurrencyLevel) // Use at least as many bins
{
initialCapacity = concurrencyLevel; // as estimated threads
}
long size = (long)(1.0 + (long)initialCapacity / loadFactor);
int cap = (size >= (long)MAXIMUM_CAPACITY) ?
MAXIMUM_CAPACITY : tableSizeFor((int)size);
this.sizeCtl = cap;
myHashingStrategy = hashingStrategy == THIS ? this : hashingStrategy;
}
示例13: createWithStrategy
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public static <K,V> StripedLockConcurrentHashMap<K,V> createWithStrategy(@NotNull final TObjectHashingStrategy<K> hashingStrategy, int initialCapacity) {
return new StripedLockConcurrentHashMap<K, V>(initialCapacity){
@Override
protected TObjectHashingStrategy<K> getHashingStrategy() {
return hashingStrategy;
}
};
}
示例14: classify
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
@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();
}
};
}
});
}
示例15: processChildren
import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public void processChildren(@NotNull Processor<SliceUsage> processor) {
final PsiElement element = ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
@Override
public PsiElement compute() {
return getElement();
}
});
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
indicator.checkCanceled();
final Processor<SliceUsage> uniqueProcessor =
new CommonProcessors.UniqueProcessor<SliceUsage>(processor, new TObjectHashingStrategy<SliceUsage>() {
@Override
public int computeHashCode(final SliceUsage object) {
return object.getUsageInfo().hashCode();
}
@Override
public boolean equals(final SliceUsage o1, final SliceUsage o2) {
return o1.getUsageInfo().equals(o2.getUsageInfo());
}
});
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
if (params.dataFlowToThis) {
processUsagesFlownDownTo(element, uniqueProcessor);
}
else {
processUsagesFlownFromThe(element, uniqueProcessor);
}
}
});
}