Returns the elements of a
NavigableSet,
unfiltered, that
satisfy a predicate. The returned set is a live view of
unfiltered;
changes to one affect the other.
The resulting set's iterator does not support
remove(), but all
other set methods are supported. When given an element that doesn't satisfy
the predicate, the set's
add() and
addAll() methods throw
an
IllegalArgumentException. When methods such as
removeAll() and
clear() are called on the filtered set,
only elements that satisfy the filter will be removed from the underlying
set.
The returned set isn't threadsafe or serializable, even if
unfiltered is.
Many of the filtered set's methods, such as
size(), iterate across
every element in the underlying set and determine which elements satisfy
the filter. When a live view is not needed, it may be faster to copy
Iterables.filter(unfiltered, predicate) and use the copy.
Warning:
predicate must be consistent with equals,
as documented at
Predicate#apply. Do not provide a predicate such as
Predicates.instanceOf(ArrayList.class), which is inconsistent with
equals. (See
Iterables#filter(Iterable,Class) for related
functionality.)