• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TObjectHashingStrategy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中gnu.trove.TObjectHashingStrategy的典型用法代码示例。如果您正苦于以下问题:Java TObjectHashingStrategy类的具体用法?Java TObjectHashingStrategy怎么用?Java TObjectHashingStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TObjectHashingStrategy类属于gnu.trove包,在下文中一共展示了TObjectHashingStrategy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: getPropertiesKeys

import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
static Set<Object> getPropertiesKeys(final PropertyReferenceBase propertyReference) {
  final Set<Object> variants = new THashSet<Object>(new TObjectHashingStrategy<Object>() {
    public int computeHashCode(final Object object) {
      if (object instanceof IProperty) {
        final String key = ((IProperty)object).getKey();
        return key == null ? 0 : key.hashCode();
      }
      else {
        return 0;
      }
    }

    public boolean equals(final Object o1, final Object o2) {
      return o1 instanceof IProperty && o2 instanceof IProperty &&
             Comparing.equal(((IProperty)o1).getKey(), ((IProperty)o2).getKey(), true);
    }
  });
  List<PropertiesFile> propertiesFileList = propertyReference.getPropertiesFiles();
  if (propertiesFileList == null) {
    PropertiesReferenceManager
      .getInstance(propertyReference.getElement().getProject()).processAllPropertiesFiles(new PropertiesFileProcessor() {
      @Override
      public boolean process(String baseName, PropertiesFile propertiesFile) {
        addVariantsFromFile(propertyReference, propertiesFile, variants);
        return true;
      }
    });
  }
  else {
    for (PropertiesFile propFile : propertiesFileList) {
      addVariantsFromFile(propertyReference, propFile, variants);
    }
  }
  return variants;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:PropertiesPsiCompletionUtil.java


示例17: processChildren

import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public void processChildren(Processor<SliceUsage> processor) {
  final PsiElement element = 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) {
        SliceUtil.processUsagesFlownDownTo(element, uniqueProcessor, SliceUsage.this, mySubstitutor);
      }
      else {
        SliceFUtil.processUsagesFlownFromThe(element, uniqueProcessor, SliceUsage.this);
      }
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:SliceUsage.java


示例18: convertKToKeyK

import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
@NotNull
private static <K,V> TObjectHashingStrategy<Key<K, V>> convertKToKeyK(@NotNull final TObjectHashingStrategy<K> hashingStrategy) {
  return new TObjectHashingStrategy<Key<K, V>>() {
    @Override
    public int computeHashCode(final Key<K, V> object) {
      return hashingStrategy.computeHashCode(object.get());
    }

    @Override
    public boolean equals(final Key<K, V> o1, final Key<K, V> o2) {
      return hashingStrategy.equals(o1.get(), o2.get());
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:ConcurrentRefHashMap.java


示例19: ConcurrentHashMap

import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
public ConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel, TObjectHashingStrategy<K> hashingStrategy) {
  if (!(loadFactor > 0) || initialCapacity < 0 || concurrencyLevel <= 0)
    throw new IllegalArgumentException();

  if (concurrencyLevel > MAX_SEGMENTS)
    concurrencyLevel = MAX_SEGMENTS;

  // Find power-of-two sizes best matching arguments
  int sshift = 0;
  int ssize = 1;
  while (ssize < concurrencyLevel) {
    ++sshift;
    ssize <<= 1;
  }
  segmentShift = 12; // the middle of the hash is much more random that its HSB. Especially when we use TObjectHashingStrategy.CANONICAl as a hash provider
  segmentMask = ssize - 1;
  segments = new Segment[ssize];

  if (initialCapacity > MAXIMUM_CAPACITY)
    initialCapacity = MAXIMUM_CAPACITY;
  int c = initialCapacity / ssize;
  if (c * ssize < initialCapacity)
    ++c;
  int cap = 1;
  while (cap < c)
    cap <<= 1;

  hashingStrategy = hashingStrategy == null ? this : hashingStrategy;
  for (int i = 0; i < segments.length; ++i)
    segments[i] = new Segment<K,V>(cap, loadFactor,hashingStrategy);
  myHashingStrategy = hashingStrategy;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:ConcurrentHashMap.java


示例20: testKeysRemovedWhenIdentityStrategyIsUsed

import gnu.trove.TObjectHashingStrategy; //导入依赖的package包/类
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());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:ConcurrentWeakHashMapTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Pseudograph类代码示例发布时间:2022-05-21
下一篇:
Java ResponseCodeHandler类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap