本文整理了Java中com.google.common.collect.Multiset.removeAll()
方法的一些代码示例,展示了Multiset.removeAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Multiset.removeAll()
方法的具体详情如下:
包路径:com.google.common.collect.Multiset
类名称: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
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testElementSetReflectsRemove() {
Set<E> elementSet = getMultiset().elementSet();
assertTrue(elementSet.contains(e0()));
getMultiset().removeAll(Collections.singleton(e0()));
assertFalse(elementSet.contains(e0()));
}
代码示例来源:origin: google/guava
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllIgnoresCount() {
initThreeCopies();
assertTrue(getMultiset().removeAll(Collections.singleton(e0())));
assertEmpty(getMultiset());
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public boolean removeAll(Collection<?> arg0) {
return multiset.removeAll(arg0);
}
代码示例来源:origin: pl.edu.icm.sedno/sedno-tools
private static Multiset<String> createWordsMultiset(String a) {
Multiset<String> wordsMultisetOfA = HashMultiset.create();
wordsMultisetOfA.addAll(tokenizeAndFilterAC(a));
wordsMultisetOfA.removeAll(PL_STOPWORDS);
return wordsMultisetOfA;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static ListDiff<Binding> compareUnordered(ResultSet a, ResultSet b) {
ListDiff<Binding> result = new ListDiff<>();
Multiset<Binding> x = toMultiset(a);
Multiset<Binding> y = toMultiset(b);
Multiset<Binding> common = HashMultiset.create(Multisets.intersection(x, y));
y.removeAll(common);
x.removeAll(common);
result.getAdded().addAll(y);
result.getRemoved().addAll(x);
return result;
}
代码示例来源:origin: Stratio/wikipedia-parser
public ImmutableMultiset<String> getTokenCountMultiset() {
if (_tokenCountMultiset == null) {
Multiset<String> m = HashMultiset.create(newRevision.getTokens());
m.removeAll(oldRevision.getTokens());
_tokenCountMultiset = ImmutableMultiset.copyOf(m);
}
return _tokenCountMultiset;
}
代码示例来源:origin: com.google.guava/guava-testlib-jdk5
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testElementSetReflectsRemove() {
Set<E> elementSet = getMultiset().elementSet();
assertTrue(elementSet.contains(samples.e0));
getMultiset().removeAll(Collections.singleton(samples.e0));
assertFalse(elementSet.contains(samples.e0));
}
代码示例来源:origin: com.google.guava/guava-testlib
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testElementSetReflectsRemove() {
Set<E> elementSet = getMultiset().elementSet();
assertTrue(elementSet.contains(e0()));
getMultiset().removeAll(Collections.singleton(e0()));
assertFalse(elementSet.contains(e0()));
}
代码示例来源:origin: com.google.javascript/closure-compiler
@Override
public final void visit(NodeTraversal traversal, Node n, Node parent) {
// Remove any guards registered on this node by its children, which are no longer
// relevant. This happens first because these were registered on a "parent", but
// now this is that parent (i.e. `n` here vs `parent` in isGuarded).
if (parent != null && CAN_HAVE_GUARDS.contains(n.getToken())
&& installedGuards.containsKey(n)) {
guarded.removeAll(installedGuards.removeAll(n));
}
// Check for abrupt returns (`return` and `throw`).
if (isAbrupt(n)) {
// If found, any guards installed on a parent IF should be promoted to the
// grandparent. This allows a small amount of flow-sensitivity, in that
// if (!x) return; x();
// has the guard for `x` promoted from the `if` to the outer block, so that
// it guards the next statement.
promoteAbruptReturns(parent);
}
// Finally continue on to whatever the traversal would normally do.
visitGuarded(traversal, n, parent);
// After children have been traversed, pop the top of the conditional stack.
contextStack.pop();
}
代码示例来源:origin: com.google.guava/guava-testlib
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllIgnoresCount() {
initThreeCopies();
assertTrue(getMultiset().removeAll(Collections.singleton(e0())));
assertEmpty(getMultiset());
}
代码示例来源:origin: com.google.guava/guava-testlib-jdk5
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveAllIgnoresCount() {
initThreeCopies();
assertTrue(getMultiset().removeAll(Collections.singleton(samples.e0)));
ASSERT.that(getMultiset()).isEmpty();
}
代码示例来源:origin: kframework/k
private void handleBinderVariables(KItem kItem, boolean add) {
// TODO(AndreiS): fix binder when dealing with KLabel variables and non-concrete KLists
if (!(kItem.kLabel() instanceof KLabel) || !(kItem.kList() instanceof KList)) {
return;
}
KLabel kLabel = (KLabel) kItem.kLabel();
KList kList = (KList) kItem.kList();
if (kLabel instanceof KLabelConstant) {
KLabelConstant kLabelConstant = (KLabelConstant) kLabel;
if (kLabelConstant.isBinder()) { // if label is a binder rename all bound variables
Multimap<Integer, Integer> binderMap = kLabelConstant.getBinderMap();
for (Integer keyIndex : binderMap.keySet()) {
//since a pattern can be on a binding position, we need to collect and bind all variables in the pattern
if (add) {
boundVariables.addAll(kList.get(keyIndex).userVariableSet(kItem.globalContext()));
} else {
boundVariables.removeAll(kList.get(keyIndex).userVariableSet(kItem.globalContext()));
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!