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

Method filter

output/java_guava/1.4.19/Multisets.java:288–298  ·  view source on GitHub ↗

Returns a view of the elements of unfiltered that satisfy a predicate. The returned multiset is a live view of unfiltered; changes to one affect the other. The resulting multiset's iterators, and those of its entrySet() and elementSet(), do not support {@code remo

(Multiset<E> unfiltered, Predicate<? super E> predicate)

Source from the content-addressed store, hash-verified

286 */
287
288 @Beta
289 public static <E> Multiset<E> filter(Multiset<E> unfiltered, Predicate<? super E> predicate) {
290 if (unfiltered instanceof FilteredMultiset) {
291 // Support clear(), removeAll(), and retainAll() when filtering a filtered
292 // collection.
293 FilteredMultiset<E> filtered = (FilteredMultiset<E>) unfiltered;
294 Predicate<E> combinedPredicate = Predicates.<E>and(filtered.predicate, predicate);
295 return new FilteredMultiset<E>(filtered.unfiltered, combinedPredicate);
296 }
297 return new FilteredMultiset<E>(unfiltered, predicate);
298 }
299
300 private static final class FilteredMultiset<E> extends AbstractMultiset<E> {
301 final Multiset<E> unfiltered;

Callers 1

createKeysMethod · 0.95

Calls 1

andMethod · 0.95

Tested by

no test coverage detected