public static < E > List < E > find ( Iterator < E > iterator , Predicate < E > predicate ) { final Function < Iterator < E > , ArrayList < E > > consumer = new ConsumeIntoCollection <> ( new ArrayListFactory < E > ( ) ) ; final FilteringIterator < E > filtered = new FilteringIterator < E > ( iterator , predicate ) ; final ArrayList < E > found = consumer . apply ( filtered ) ; dbc . precondition ( ! found . isEmpty ( ) , "no element matched" ) ; return found ; }
Searches the iterator consuming it yielding every value matching the predicate . An IllegalStateException is thrown if no element matches .