static < T > List < T > filter ( List < T > list , Predicate < T > predicate ) { List < T > results = new ArrayList <> ( ) ; for ( T current : list ) { if ( predicate . apply ( current ) ) { results . add ( current ) ; } } return results ; }
Filter input by using given predicate and return filtered outputs .