code: public static <E> void retainAll(Collection<E> elems, Filter<? super E> filter) {
      for (Iterator<E> iter = elems.iterator(); iter.hasNext();) {
        E elem = iter.next();
        if ( ! filter.accept(elem)) {
          iter.remove();
        }
      }
    }
docs: Removes all elems in the given Collection that aren't accepted by the given Filter.