(Changed in version 2.8.0) collect
has changed. The previous behavior can be reproduced with toSeq
.
Called exactly once, when the iterator is empty
Called exactly once, when the iterator is empty
Compute the next element, if it hasn't already been computed; the result is stored in _next.
Compute the next element, if it hasn't already been computed; the result is stored in _next.
Hook for subclasses to update books after each element is consumed.
Hook for subclasses to update books after each element is consumed.
Interface for implementing BufferedIterators following a common pattern: the
hasNext
implementation must actually compute the next element (or return a sentinel that implies that one doesn't exist), and should therefore cache that element to servehead
andnext()
calls.This interface allows subclasses to simply implement an
_advance
method that returns an Option containing the next element, if one exists, and None otherwise, and it takes care of the rest of the boilerplate.It also exposes protected
clear
andpostNext
methods for Noneing the internal state and responding tonext()
having been called, respectively.