ramhiser/itertools2

hasNext

Opened this issue · 1 comments

Do you have plans to implement hasNext method (similar to itertools::hasNext)?
EDIT: Also itertools::ihasNext() is very useful.

@dselivanov I have thought about creating a hasNext that is similar to itertools::ihasNext(). The implementation in itertools goes against the concept of an iterator because it maintains state. While it may be useful for some use cases, I am not fond of the caching it performs when determining whether another element is available. For a large cached chunk, say, a large data.frame queried from a database, the cache may be excessively large in terms of memory.

It may be possible though to implement such an approach with itertools2::itee. I'd be open to a PR with a suggested implementation.