Java 8 Streams API - Stream-Level Predicates: Difference between revisions
No edit summary |
|||
Line 42: | Line 42: | ||
Returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated. | Returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated. | ||
<syntaxhighlight lang='java'> | |||
public interface Stream<T> ... { | |||
boolean noneMatch(Predicate<? super T> predicate); | |||
} | |||
</syntaxhighlight> |
Latest revision as of 20:09, 28 March 2018
Internal
Overview
These "match" operations apply a predicate to all elements of the stream, subject to short-circuiting, and return a boolean result. Any of these operations are terminal, in that they return a boolean (non-stream) result.
Methods
anyMatch
Returns whether any elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then false is returned and the predicate is not evaluated.
public interface Stream<T> ... {
boolean anyMatch(Predicate<? super T> predicate);
}
allMatch
Returns whether all elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated.
public interface Stream<T> ... {
boolean allMatch(Predicate<? super T> predicate);
}
noneMatch
Returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated.
public interface Stream<T> ... {
boolean noneMatch(Predicate<? super T> predicate);
}