当前位置: 首页>>代码示例>>Java>>正文


Java TObjectHashingStrategy类代码示例

本文整理汇总了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;
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:17,代码来源:DuplicatesUtil.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ValidationConfigurable.java

示例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);
    }
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:MultiMap.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:VfsData.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ConcurrentMapsTest.java

示例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);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:MultiMap.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ConcurrentWeakKeySoftValueHashMap.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ConcurrentWeakKeySoftValueHashMap.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ConcurrentRefHashMap.java

示例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());
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:RefHashMap.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ConcurrentHashMap.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ConcurrentHashMap.java

示例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;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:StripedLockConcurrentHashMap.java

示例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();
        }
      };
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:StatisticsWeigher.java

示例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);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:SliceUsage.java


注:本文中的gnu.trove.TObjectHashingStrategy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。