com.google.common.collect.Multiset.removeAll()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中com.google.common.collect.Multiset.removeAll()方法的一些代码示例,展示了Multiset.removeAll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multiset.removeAll()方法的具体详情如下:
包路径:com.google.common.collect.Multiset
类名称:Multiset
方法名:removeAll

Multiset.removeAll介绍

[英]Note: This method ignores how often any element might appear in c, and only cares whether or not an element appears at all. If you wish to remove one occurrence in this multiset for every occurrence in c, see Multisets#removeOccurrences(Multiset,Multiset).

This method refines Collection#removeAll to further specify that it may not throw an exception in response to any of elementsbeing null or of the wrong type.
[中]注意:此方法忽略任何元素在c中出现的频率,只关心元素是否出现。如果希望为c中的每个事件删除此multiset中的一个事件,请参见multiset#RemoveOccessions(multiset,multiset)。
此方法细化了Collection#removeAll,以进一步指定它不会在响应任何元素为null或类型错误时引发异常。

代码示例

代码示例来源:origin: google/guava

  1. @CollectionSize.Require(absent = ZERO)
  2. @CollectionFeature.Require(SUPPORTS_REMOVE)
  3. public void testElementSetReflectsRemove() {
  4. Set<E> elementSet = getMultiset().elementSet();
  5. assertTrue(elementSet.contains(e0()));
  6. getMultiset().removeAll(Collections.singleton(e0()));
  7. assertFalse(elementSet.contains(e0()));
  8. }

代码示例来源:origin: google/guava

  1. @CollectionSize.Require(SEVERAL)
  2. @CollectionFeature.Require(SUPPORTS_REMOVE)
  3. public void testRemoveAllIgnoresCount() {
  4. initThreeCopies();
  5. assertTrue(getMultiset().removeAll(Collections.singleton(e0())));
  6. assertEmpty(getMultiset());
  7. }

代码示例来源:origin: aadnk/ProtocolLib

  1. @Override
  2. public boolean removeAll(Collection<?> arg0) {
  3. return multiset.removeAll(arg0);
  4. }

代码示例来源:origin: pl.edu.icm.sedno/sedno-tools

  1. private static Multiset<String> createWordsMultiset(String a) {
  2. Multiset<String> wordsMultisetOfA = HashMultiset.create();
  3. wordsMultisetOfA.addAll(tokenizeAndFilterAC(a));
  4. wordsMultisetOfA.removeAll(PL_STOPWORDS);
  5. return wordsMultisetOfA;
  6. }

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

  1. public static ListDiff<Binding> compareUnordered(ResultSet a, ResultSet b) {
  2. ListDiff<Binding> result = new ListDiff<>();
  3. Multiset<Binding> x = toMultiset(a);
  4. Multiset<Binding> y = toMultiset(b);
  5. Multiset<Binding> common = HashMultiset.create(Multisets.intersection(x, y));
  6. y.removeAll(common);
  7. x.removeAll(common);
  8. result.getAdded().addAll(y);
  9. result.getRemoved().addAll(x);
  10. return result;
  11. }

代码示例来源:origin: Stratio/wikipedia-parser

  1. public ImmutableMultiset<String> getTokenCountMultiset() {
  2. if (_tokenCountMultiset == null) {
  3. Multiset<String> m = HashMultiset.create(newRevision.getTokens());
  4. m.removeAll(oldRevision.getTokens());
  5. _tokenCountMultiset = ImmutableMultiset.copyOf(m);
  6. }
  7. return _tokenCountMultiset;
  8. }

代码示例来源:origin: com.google.guava/guava-testlib-jdk5

  1. @CollectionSize.Require(absent = ZERO)
  2. @CollectionFeature.Require(SUPPORTS_REMOVE)
  3. public void testElementSetReflectsRemove() {
  4. Set<E> elementSet = getMultiset().elementSet();
  5. assertTrue(elementSet.contains(samples.e0));
  6. getMultiset().removeAll(Collections.singleton(samples.e0));
  7. assertFalse(elementSet.contains(samples.e0));
  8. }

代码示例来源:origin: com.google.guava/guava-testlib

  1. @CollectionSize.Require(absent = ZERO)
  2. @CollectionFeature.Require(SUPPORTS_REMOVE)
  3. public void testElementSetReflectsRemove() {
  4. Set<E> elementSet = getMultiset().elementSet();
  5. assertTrue(elementSet.contains(e0()));
  6. getMultiset().removeAll(Collections.singleton(e0()));
  7. assertFalse(elementSet.contains(e0()));
  8. }

代码示例来源:origin: com.google.javascript/closure-compiler

  1. @Override
  2. public final void visit(NodeTraversal traversal, Node n, Node parent) {
  3. // Remove any guards registered on this node by its children, which are no longer
  4. // relevant. This happens first because these were registered on a "parent", but
  5. // now this is that parent (i.e. `n` here vs `parent` in isGuarded).
  6. if (parent != null && CAN_HAVE_GUARDS.contains(n.getToken())
  7. && installedGuards.containsKey(n)) {
  8. guarded.removeAll(installedGuards.removeAll(n));
  9. }
  10. // Check for abrupt returns (`return` and `throw`).
  11. if (isAbrupt(n)) {
  12. // If found, any guards installed on a parent IF should be promoted to the
  13. // grandparent. This allows a small amount of flow-sensitivity, in that
  14. // if (!x) return; x();
  15. // has the guard for `x` promoted from the `if` to the outer block, so that
  16. // it guards the next statement.
  17. promoteAbruptReturns(parent);
  18. }
  19. // Finally continue on to whatever the traversal would normally do.
  20. visitGuarded(traversal, n, parent);
  21. // After children have been traversed, pop the top of the conditional stack.
  22. contextStack.pop();
  23. }

代码示例来源:origin: com.google.guava/guava-testlib

  1. @CollectionSize.Require(SEVERAL)
  2. @CollectionFeature.Require(SUPPORTS_REMOVE)
  3. public void testRemoveAllIgnoresCount() {
  4. initThreeCopies();
  5. assertTrue(getMultiset().removeAll(Collections.singleton(e0())));
  6. assertEmpty(getMultiset());
  7. }

代码示例来源:origin: com.google.guava/guava-testlib-jdk5

  1. @CollectionSize.Require(SEVERAL)
  2. @CollectionFeature.Require(SUPPORTS_REMOVE)
  3. public void testRemoveAllIgnoresCount() {
  4. initThreeCopies();
  5. assertTrue(getMultiset().removeAll(Collections.singleton(samples.e0)));
  6. ASSERT.that(getMultiset()).isEmpty();
  7. }

代码示例来源:origin: kframework/k

  1. private void handleBinderVariables(KItem kItem, boolean add) {
  2. // TODO(AndreiS): fix binder when dealing with KLabel variables and non-concrete KLists
  3. if (!(kItem.kLabel() instanceof KLabel) || !(kItem.kList() instanceof KList)) {
  4. return;
  5. }
  6. KLabel kLabel = (KLabel) kItem.kLabel();
  7. KList kList = (KList) kItem.kList();
  8. if (kLabel instanceof KLabelConstant) {
  9. KLabelConstant kLabelConstant = (KLabelConstant) kLabel;
  10. if (kLabelConstant.isBinder()) { // if label is a binder rename all bound variables
  11. Multimap<Integer, Integer> binderMap = kLabelConstant.getBinderMap();
  12. for (Integer keyIndex : binderMap.keySet()) {
  13. //since a pattern can be on a binding position, we need to collect and bind all variables in the pattern
  14. if (add) {
  15. boundVariables.addAll(kList.get(keyIndex).userVariableSet(kItem.globalContext()));
  16. } else {
  17. boundVariables.removeAll(kList.get(keyIndex).userVariableSet(kItem.globalContext()));
  18. }
  19. }
  20. }
  21. }
  22. }

相关文章