code: public static <T> Number count(Iterator<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure closure) {
          long answer = 0;
          BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure);
          while (self.hasNext()) {
              if (bcw.call(self.next())) {
                  ++answer;
              }
          }
          // for b/c with Java return an int if we can
          if (answer <= Integer.MAX_VALUE) return (int) answer;
          return answer;
      }
docs: Counts the number of occurrences which satisfy the given closure from the
  items within this Iterator.
  The iterator will become exhausted of elements after determining the count value.
  <p>
  Example usage:
  <pre class="groovyTestCase">assert [2,4,2,1,3,5,2,4,3].toSet().iterator().count{ it % 2 == 0 } == 2</pre>
  
  @param self  the Iterator from which we count the number of matching occurrences
  @param closure a closure condition
  @return the number of occurrences
  @since 1.8.0