Traverses an iterator and removes every element that does not belong to the provided collection. The iterator will be left exhausted: its hasNext() method will return false. @param removeFrom the iterator to (potentially) remove elements from @param elementsToRetain the elements to
(Iterator<?> removeFrom, Collection<?> elementsToRetain)
| 258 | * @return {@code true} if any element was removed from {@code iterator} |
| 259 | */ |
| 260 | @CanIgnoreReturnValue |
| 261 | public static boolean retainAll(Iterator<?> removeFrom, Collection<?> elementsToRetain) { |
| 262 | return removeIf(removeFrom, not(in(elementsToRetain))); |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Determines whether two iterators contain equal elements in the same order. |