code: public static Number count(Iterator self, Object value) {
          long answer = 0;
          while (self.hasNext()) {
              if (DefaultTypeTransformation.compareEqual(self.next(), value)) {
                  ++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 of the given value from the
  items within this Iterator.
  Comparison is done using Groovy's == operator (using
  <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
  The iterator will become exhausted of elements after determining the count value.
  
  @param self  the Iterator from which we count the number of matching occurrences
  @param value the value being searched for
  @return the number of occurrences
  @since 1.5.0