@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())); }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemoveAllIgnoresCount() { initThreeCopies(); assertTrue(getMultiset().removeAll(Collections.singleton(e0()))); assertEmpty(getMultiset()); }
@Override public boolean removeAll(Collection<?> arg0) { return multiset.removeAll(arg0); }
private static Multiset<String> createWordsMultiset(String a) { Multiset<String> wordsMultisetOfA = HashMultiset.create(); wordsMultisetOfA.addAll(tokenizeAndFilterAC(a)); wordsMultisetOfA.removeAll(PL_STOPWORDS); return wordsMultisetOfA; }
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; }
public ImmutableMultiset<String> getTokenCountMultiset() { if (_tokenCountMultiset == null) { Multiset<String> m = HashMultiset.create(newRevision.getTokens()); m.removeAll(oldRevision.getTokens()); _tokenCountMultiset = ImmutableMultiset.copyOf(m); } return _tokenCountMultiset; }
@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)); }
@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())); }
@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(); }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemoveAllIgnoresCount() { initThreeCopies(); assertTrue(getMultiset().removeAll(Collections.singleton(e0()))); assertEmpty(getMultiset()); }
@CollectionSize.Require(SEVERAL) @CollectionFeature.Require(SUPPORTS_REMOVE) public void testRemoveAllIgnoresCount() { initThreeCopies(); assertTrue(getMultiset().removeAll(Collections.singleton(samples.e0))); ASSERT.that(getMultiset()).isEmpty(); }
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())); } } } } }