I always lived under the impression that after calling it.take(n)
the original iterator it
must be discarded, as it is left in an undefined state. Some implementations, for example NewVectorIterator
, implement an optimization by essentially changing the semantics to takeInPlace
.
However, now I see no documentation mentioning that, like in the case of copyToArray
. SliceIterator
does not, for example, use this optimization.
Additionally, it may even be unintuitive behaviour. In this situation I am not sure where I stand. If the original iterator is left in an undefined state by essentially all methods other than hasNext
, next()
, and take
, then we can make such optimizations. If not, then splitting iterator contents (doing something with the first n
elements, and something else with the rest) becomes that much easier, as it doesn’t require calling splitAt
. As it is, we got the worst of both worlds.
Is it only an ommission in the docummentation and the intent was always clear(), or is it a bit of a whole in the language semantics?