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

Method remove

output/java_guava/1.4.17/Multimaps.java:1691–1712  ·  view source on GitHub ↗
(@Nullable Object element, int occurrences)

Source from the content-addressed store, hash-verified

1689 }
1690
1691 @Override
1692 public int remove(@Nullable Object element, int occurrences) {
1693 checkNonnegative(occurrences, "occurrences");
1694 if (occurrences == 0) {
1695 return count(element);
1696 }
1697 Collection<V> values = Maps.safeGet(multimap.asMap(), element);
1698 if (values == null) {
1699 return 0;
1700 }
1701 int oldCount = values.size();
1702 if (occurrences >= oldCount) {
1703 values.clear();
1704 } else {
1705 Iterator<V> iterator = values.iterator();
1706 for (int i = 0; i < occurrences; i++) {
1707 iterator.next();
1708 iterator.remove();
1709 }
1710 }
1711 return oldCount;
1712 }
1713
1714 @Override
1715 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