MCPcopy Create free account
hub / github.com/antlr/codebuff / remove

Method remove

corpus/java/training/guava/collect/Multimaps.java:1656–1680  ·  view source on GitHub ↗
(@Nullable Object element, int occurrences)

Source from the content-addressed store, hash-verified

1654 }
1655
1656 @Override
1657 public int remove(@Nullable Object element, int occurrences) {
1658 checkNonnegative(occurrences, "occurrences");
1659 if (occurrences == 0) {
1660 return count(element);
1661 }
1662
1663 Collection<V> values = Maps.safeGet(multimap.asMap(), element);
1664
1665 if (values == null) {
1666 return 0;
1667 }
1668
1669 int oldCount = values.size();
1670 if (occurrences >= oldCount) {
1671 values.clear();
1672 } else {
1673 Iterator<V> iterator = values.iterator();
1674 for (int i = 0; i < occurrences; i++) {
1675 iterator.next();
1676 iterator.remove();
1677 }
1678 }
1679 return oldCount;
1680 }
1681
1682 @Override
1683 public void clear() {

Callers

nothing calls this directly

Calls 9

countMethod · 0.95
safeGetMethod · 0.95
asMapMethod · 0.65
sizeMethod · 0.65
clearMethod · 0.65
iteratorMethod · 0.65
nextMethod · 0.65
removeMethod · 0.65
checkNonnegativeMethod · 0.45

Tested by

no test coverage detected