MCPcopy
hub / github.com/google/guava / filter

Method filter

guava/src/com/google/common/collect/Sets.java:1187–1201  ·  view source on GitHub ↗
(
      Set<E> unfiltered, Predicate<? super E> predicate)

Source from the content-addressed store, hash-verified

1185 */
1186 // TODO(kevinb): how to omit that last sentence when building GWT javadoc?
1187 public static <E extends @Nullable Object> Set<E> filter(
1188 Set<E> unfiltered, Predicate<? super E> predicate) {
1189 if (unfiltered instanceof SortedSet) {
1190 return filter((SortedSet<E>) unfiltered, predicate);
1191 }
1192 if (unfiltered instanceof FilteredSet) {
1193 // Support clear(), removeAll(), and retainAll() when filtering a filtered
1194 // collection.
1195 FilteredSet<E> filtered = (FilteredSet<E>) unfiltered;
1196 Predicate<E> combinedPredicate = Predicates.and(filtered.predicate, predicate);
1197 return new FilteredSet<>((Set<E>) filtered.unfiltered, combinedPredicate);
1198 }
1199
1200 return new FilteredSet<>(checkNotNull(unfiltered), checkNotNull(predicate));
1201 }
1202
1203 /**
1204 * Returns the elements of a {@code SortedSet}, {@code unfiltered}, that satisfy a predicate. The

Callers 15

createEntrySetMethod · 0.95
createKeySetMethod · 0.95
FilteredEntryMapMethod · 0.95
filterCollectionMethod · 0.95
createElementSetMethod · 0.95
createEntrySetMethod · 0.95
descendingSetMethod · 0.95
createEntriesMethod · 0.95
createKeySetMethod · 0.95
edgesConnectingMethod · 0.95
createMethod · 0.95
testCombinationsMethod · 0.95

Calls 2

andMethod · 0.95
checkNotNullMethod · 0.45

Tested by 5

createMethod · 0.76
testCombinationsMethod · 0.76
filterMethod · 0.76
filterMethod · 0.76
filterMethod · 0.76