Returns the number of elements in the specified iterator that equal the
specified object. The iterator will be left exhausted: its
{@code hasNext()} method will return {@code false}.

@see Collections#frequency
183687
public static int frequency(Iterator<?> iterator, @Nullable Object element) {
    return size(filter(iterator, equalTo(element)));
  }
312249
@Override
	public boolean hasNext() {

		// iterate over input data until an element is created
		while (reader.hasNext() && nextElement == null) {

			try {
				final XMLEvent event = reader.nextEvent();

				switch (event.getEventType()) {

					case XMLEvent.START_DOCUMENT:
						startDocument();
						break;

					case XMLEvent.START_ELEMENT:
						startElement(event.asStartElement());
						break;

					case XMLEvent.END_DOCUMENT:
						endDocument();
						break;

					case XMLEvent.END_ELEMENT:
						endElement(event.asEndElement());
						break;

					case XMLEvent.CHARACTERS:
					case XMLEvent.CDATA:
						characters(event.asCharacters());
						break;

				}

			} catch (XMLStreamException strex) {
				logger.warn(strex.getMessage());
				break;
			}
		}

		// either an element has been created, or the stream is at its end
		return nextElement != null;
	}
977557
@Override
	public boolean hasNext() {
		if (next == null) {
			try {
				next = readNextFromStream();
			} catch (Exception e) {
				throw new RuntimeException("Failed to receive next element: " + e.getMessage(), e);
			}
		}

		return next != null;
	}
911090
@SuppressWarnings("unchecked")
  public static Iterator<Object> iterator(Object iterable) {
    Assert.state(isIterable(iterable.getClass()));
    return iterable.getClass().isArray() ? new ArrayIterator(iterable)
        : ((Iterable<Object>) iterable).iterator();
  }
512678
public Iterator iterator() {
        return new Iterator() {
            public boolean hasNext() {
                return false;
            }

            public Object next() {
                return null;
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
1332830
@Override
    public Iterator<Object> iterator() {
        return new Iterator<Object>() {
            Iterator<Object> iter = list.listIterator();

            @Override
            public boolean hasNext() {
                return iter.hasNext();
            }

            @Override
            public Object next() {
                return iter.next();
            }

            @Override
            public void remove() {
                iter.remove();
            }
        };
    }
640054
private <T> Iterator<T> emptyIt() {
        return new Iterator<T>() {
            @Override
            public boolean hasNext() {
                return false;
            }
            @Override
            public T next() {
                return null;
            }
        };
    }
134337
@Override
  public Iterator<Page<T>> iterator() {

    return new Iterator<Page<T>>() {

      int currentIndex = 0;
      int currentPageNumber = 1;
      int pageSize = getPageSize();

      @Override
      public boolean hasNext() {
        return this.currentIndex < getList().size();
      }

      @Override
      public Page<T> next() {

        Assert.isTrue(hasNext(), new NoSuchElementException("No more pages"));

        Page<T> page = SimplePage.of(SimplePageable.this, this.currentPageNumber);

        this.currentIndex += this.pageSize;
        this.currentPageNumber++;

        return page;
      }
    };
  }
1087664
function() {
         if(this._collection.getAll()[this._pos + 1]) {
             this._hasNext = true;
         } else {
             this._hasNext = false;
         }
         
         if(!this._nextCalled) {
             this._pos ++;
             this._hasNextCalled = true;
         }

         return this._hasNext;
     }
522891
public static <T> int count(Iterable<T> iterable) {
        int count = 0;

        if (iterable != null) {
            Iterator<T> iter = iterable.iterator();
            while (iter.hasNext()) {
                iter.next();
                count++;
            }
        }

        return count;
    }
702170
public static boolean contains(Enumeration<?> enumeration, Object element) {
        if (enumeration != null) {
            while (enumeration.hasMoreElements()) {
                Object candidate = enumeration.nextElement();
                if (ObjectUtils.nullSafeEquals(candidate, element)) {
                    return true;
                }
            }
        }
        return false;
    }
413817
@Override
    public Iterator<Object> iterator() {
        return new Iterator<Object>() {

            int currentPosition = 0;

            @Override
            public boolean hasNext() {
                return masterSequence.size() > currentPosition;
            }

            @Override
            public Object next() {
                if (currentPosition <= masterSequence.size())
                    return masterSequence.get(currentPosition++);
                return null;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException("Remove is not supported.");

            }

        };
    }
1033733
public static long count(Iterator<String> iterator) {
        if (iterator == null) {
            return 0;
        }
        long count = 0;
        while (iterator.hasNext()) {
            ++count;
            iterator.next();
        }
        return count;
    }
265192
@Override
    public boolean hasNext() {
        if(next != null){
            return true;
        }
        if(!recordReader.hasNext()){
            return false;
        }

        //Prefetch, until we find one that isn't filtered out - or we run out of data
        while(next == null && recordReader.hasNext()){
            Record r = recordReader.nextRecord();
            List<Writable> temp = transformProcess.execute(r.getRecord());
            if(temp == null){
                continue;
            }
            next = new org.datavec.api.records.impl.Record(temp, r.getMetaData());
        }

        return next != null;
    }
688733
@Override
    public boolean hasNext() {
        if (iterationsCounter.get() >= totalIterations)
            return false;

        if (newEpoch) {
            log.info("Epoch " + epochs + ", number of batches completed " + lastBatch);
            newEpoch = false;
        }
        if (iter == null)
            return (epochs < numEpochs) && ((!batchedDS.isEmpty() && batchedDS.size() > batch) || batchedDS.isEmpty());
        else
            // either there are still epochs to complete or its the first epoch
            return (epochs < numEpochs) || (iter.hasNext() && (epochs == 0 || epochs == numEpochs));
    }
181035
public static boolean contains(Iterator<?> iterator, Object element) {
        if (iterator != null) {
            while (iterator.hasNext()) {
                Object candidate = iterator.next();
                if (ObjectUtils.nullSafeEquals(candidate, element)) {
                    return true;
                }
            }
        }
        return false;
    }
768088
public static <E> long count(Iterable<E> iterable) {
        dbc.precondition(iterable != null, "cannot call count with a null iterable");
        return count(iterable.iterator());
    }