public static < T > boolean retainAll ( Collection < T > self , @ ClosureParams ( FirstParam . FirstGenericType . class ) Closure condition ) { Iterator iter = InvokerHelper . asIterator ( self ) ; BooleanClosureWrapper bcw = new BooleanClosureWrapper ( condition ) ; boolean result = false ; while ( iter . hasNext ( ) ) { Object value = iter . next ( ) ; if ( ! bcw . call ( value ) ) { iter . remove ( ) ; result = true ; } } return result ; }
Modifies this collection so that it retains only its elements that are matched according to the specified closure condition . In other words removes from this collection all of its elements that don t match .