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)
| 268 | */ |
| 269 | |
| 270 | @CanIgnoreReturnValue |
| 271 | public static boolean retainAll(Iterator<?> removeFrom, Collection<?> elementsToRetain) { |
| 272 | return removeIf(removeFrom, not(in(elementsToRetain))); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Determines whether two iterators contain equal elements in the same order. |