public static < C extends Collection < E > , E > C search ( Iterator < E > iterator , C collection , Predicate < E > predicate ) { final Function < Iterator < E > , C > consumer = new ConsumeIntoCollection <> ( new ConstantSupplier < C > ( collection ) ) ; final FilteringIterator < E > filtered = new FilteringIterator < E > ( iterator , predicate ) ; return consumer . apply ( filtered ) ; }
Searches the iterator consuming it adding every value matching the predicate to the passed collection .