下面列出了com.intellij.psi.PsiArrayType#gnu.trove.TObjectHashingStrategy 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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);
}
};
}
private void processQueue(@Nonnull NewVirtualFileSystem fs, @Nonnull PersistentFS persistence) throws RefreshCancelledException {
TObjectHashingStrategy<String> strategy = FilePathHashingStrategy.create(fs.isCaseSensitive());
next:
while (!myRefreshQueue.isEmpty()) {
VirtualDirectoryImpl dir = (VirtualDirectoryImpl)myRefreshQueue.pullFirst();
boolean fullSync = dir.allChildrenLoaded(), succeeded;
do {
myHelper.beginTransaction();
try {
succeeded = fullSync ? fullDirRefresh(fs, persistence, strategy, dir) : partialDirRefresh(fs, persistence, strategy, dir);
}
catch (InvalidVirtualFileAccessException e) {
myHelper.endTransaction(false);
continue next;
}
myHelper.endTransaction(succeeded);
if (!succeeded && LOG.isTraceEnabled()) LOG.trace("retry: " + dir);
}
while (!succeeded);
if (myIsRecursive) {
dir.markClean();
}
}
}
@Override
public void occurrence(@Nonnull final StubIndexKey indexKey, @Nonnull final Object value) {
Map<Object, int[]> map = myResult.get(indexKey);
if (map == null) {
map = new THashMap<>((TObjectHashingStrategy<Object>)myHashingStrategyFunction.fun(indexKey));
myResult.put(indexKey, map);
}
int[] list = map.get(value);
if (list == null) {
map.put(value, new int[]{myStubIdx});
}
else {
int lastNonZero = ArrayUtil.lastIndexOfNot(list, 0);
if (lastNonZero >= 0 && list[lastNonZero] == myStubIdx) {
// second and subsequent occurrence calls for the same value are no op
return;
}
int lastZero = lastNonZero + 1;
if (lastZero == list.length) {
list = ArrayUtil.realloc(list, Math.max(4, list.length << 1));
map.put(value, list);
}
list[lastZero] = myStubIdx;
}
}
@Nonnull
public static <K, V> MultiMap<K, V> create(@Nonnull final TObjectHashingStrategy<K> strategy) {
return new MultiMap<K, V>() {
@Nonnull
@Override
protected Map<K, Collection<V>> createMap() {
return new THashMap<K, Collection<V>>(strategy);
}
};
}
public Counter(TObjectHashingStrategy<T> hs) {
m_map = new TObjectDoubleHashMap<T>(hs);
}
public IntCounter(TObjectHashingStrategy<T> hs) {
m_map = new TObjectIntHashMap<T>(hs);
}
public SingleAssignmentHashMap(TObjectHashingStrategy<K> hashingStrategy) {
this(hashingStrategy, ReassignmentPolicy.ERROR);
}
public SingleAssignmentHashMap(TObjectHashingStrategy<K> hashingStrategy, ReassignmentPolicy reassign) {
super(hashingStrategy);
}
public FactoryDefaultMap(DefaultValueFactory<V> factory, TObjectHashingStrategy<K> hashingStrategy) {
super(hashingStrategy);
this.factory = factory;
}
public TObjectIndexHashMap(TObjectHashingStrategy arg0) {
super(arg0);
}
public TObjectIndexHashMap(int arg0, float arg1, TObjectHashingStrategy arg2) {
super(arg0, arg1, arg2);
}
public TObjectIndexHashMap(int arg0, TObjectHashingStrategy arg1) {
super(arg0, arg1);
}
public OpenTHashSet(final TObjectHashingStrategy<T> strategy, final T... ts) {
super(Arrays.asList(ts), strategy);
}
public UniqueResultsQuery(@Nonnull Query<? extends T> original, @Nonnull TObjectHashingStrategy<? super M> hashingStrategy, @Nonnull Function<? super T, ? extends M> mapper) {
myOriginal = original;
myHashingStrategy = hashingStrategy;
myMapper = mapper;
}
@Nonnull
public static <T> Set<T> withCustomStrategy(T o, @Nonnull TObjectHashingStrategy<T> strategy) {
return new CustomStrategySingletonSet<T>(o, strategy);
}
@Nonnull
public static TObjectHashingStrategy<String> create(boolean caseSensitive) {
return caseSensitive ? ContainerUtil.canonicalStrategy() : CaseInsensitiveStringHashingStrategy.INSTANCE;
}
RefreshContext(@Nonnull NewVirtualFileSystem fs, @Nonnull PersistentFS persistence, @Nonnull TObjectHashingStrategy<String> strategy) {
this.fs = fs;
this.persistence = persistence;
this.strategy = strategy;
}
SequentialRefreshContext(@Nonnull NewVirtualFileSystem fs, @Nonnull PersistentFS persistentFS, @Nonnull TObjectHashingStrategy<String> strategy) {
super(fs, persistentFS, strategy);
}
ConcurrentRefreshContext(@Nonnull NewVirtualFileSystem fs, @Nonnull PersistentFS persistentFS, @Nonnull TObjectHashingStrategy<String> strategy, int parallelism) {
super(fs, persistentFS, strategy);
service = AppExecutorUtil.createBoundedApplicationPoolExecutor("Refresh Worker", parallelism);
}
@Nonnull
@Contract(pure = true)
public static <T, V> ConcurrentMap<T, V> createMap(@Nonnull TObjectHashingStrategy<T> hashStrategy) {
return new ConcurrentHashMap<>(hashStrategy);
}
private StubIndexSink(@Nonnull Function<StubIndexKey<?, ?>, TObjectHashingStrategy<?>> hashingStrategyFunction) {
myHashingStrategyFunction = hashingStrategyFunction;
}
@Nonnull
@Contract(pure = true)
public static <T> Set<T> createConcurrentSet(@Nonnull TObjectHashingStrategy<T> hashStrategy) {
return Collections.newSetFromMap(createMap(hashStrategy));
}
ConcurrentSoftHashMap(int initialCapacity, float loadFactor, int concurrencyLevel, @Nonnull TObjectHashingStrategy<? super K> hashingStrategy) {
super(initialCapacity, loadFactor, concurrencyLevel, hashingStrategy);
}
private SoftKey(@Nonnull K k, final int hash, @Nonnull TObjectHashingStrategy<? super K> strategy, @Nonnull ReferenceQueue<K> q) {
super(k, q);
myStrategy = strategy;
myHash = hash;
}
public SmartHashSet(Collection<? extends T> collection, TObjectHashingStrategy<T> strategy) {
super(collection, strategy);
}
WeakHashMap(int initialCapacity, float loadFactor, @Nonnull TObjectHashingStrategy<? super K> strategy) {
super(initialCapacity, loadFactor, strategy);
}
@Deprecated
@Nonnull
public Map<StubIndexKey, Map<Object, int[]>> indexStubTree() {
return indexStubTree(key -> TObjectHashingStrategy.CANONICAL);
}
private WeakKey(@Nonnull T k, @Nonnull TObjectHashingStrategy<? super T> strategy, @Nonnull ReferenceQueue<? super T> q) {
super(k, q);
myStrategy = strategy;
myHash = strategy.computeHashCode(k);
}
private WeakKey(@Nonnull K k, final int hash, @Nonnull TObjectHashingStrategy<? super K> strategy, @Nonnull ReferenceQueue<K> q) {
super(k, q);
myStrategy = strategy;
myHash = hash;
}
@Nonnull
@Override
protected KeyReference<K> createKeyReference(@Nonnull K key, @Nonnull TObjectHashingStrategy<? super K> hashingStrategy) {
return new WeakKey<>(key, hashingStrategy.computeHashCode(key), hashingStrategy, myReferenceQueue);
}