code: static void clear(Iterator<?> iterator) {
      checkNotNull(iterator);
      while (iterator.hasNext()) {
        iterator.next();
        iterator.remove();
      }
    }
docs: Clears the iterator using its remove method.