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

Method standardRemove

output/java_guava/1.4.18/ForwardingMap.java:170–182  ·  view source on GitHub ↗

A sensible, albeit inefficient, definition of #remove in terms of the iterator method of #entrySet. If you override #entrySet, you may wish to override #remove to forward to this implementation. Alternately, you may wish to override #remove with {@

(@Nullable Object key)

Source from the content-addressed store, hash-verified

168 */
169
170 @Beta
171 protected V standardRemove(@Nullable Object key) {
172 Iterator<Entry<K, V>> entryIterator = entrySet().iterator();
173 while (entryIterator.hasNext()) {
174 Entry<K, V> entry = entryIterator.next();
175 if (Objects.equal(entry.getKey(), key)) {
176 V value = entry.getValue();
177 entryIterator.remove();
178 return value;
179 }
180 }
181 return null;
182 }
183
184 /**
185 * A sensible definition of {@link #clear} in terms of the {@code iterator}

Callers 1

removeMethod · 0.45

Calls 8

entrySetMethod · 0.95
equalMethod · 0.95
iteratorMethod · 0.65
nextMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
removeMethod · 0.65
hasNextMethod · 0.45

Tested by

no test coverage detected