code: public static <T> int removeIf(final List<T> values, final Predicate<T> predicate)
      {
          int size = values.size();
          int total = 0;
  
          for (int i = 0; i < size; )
          {
              final T value = values.get(i);
              if (predicate.test(value))
              {
                  values.remove(i);
                  total++;
                  size--;
              }
              else
              {
                  i++;
              }
          }
  
          return total;
      }
docs: Remove element from a list if it matches a predicate.
  <p>
  <b>Note:</b> the list must implement {@link java.util.RandomAccess} to be efficient.
  
  @param values    to be iterated over.
  @param predicate to test the value against
  @param <T>       type of the value.
  @return the number of items remove.