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

Method filter

output/java_guava/1.4.18/Multisets.java:289–299  ·  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

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

Callers 1

createKeysMethod · 0.95

Calls 1

andMethod · 0.95

Tested by

no test coverage detected