Rules / Types, classes & roles / basic

PredictiveIterator Reference

Iterators that can predict number of values

What it is #

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

method count-only #

method count-only(--> Int:D) { ... }

Returns Int:D.

It is expected to return the number of values the iterator can still produce without actually producing them. The returned number must adjust itself for items already pulled, so that the method can be called on a partially consumed Iterator. It will be used in situations where only the number of values of an iterator is needed, e.g. when the .elems method is called.

method bool-only #

method bool-only(--> Bool:D) { self.count-only.Bool }

Returns Bool:D.

Defaults to the Booleanification of the result of calling the count-only method. If it is possible to have a faster way of finding out whether the iterator is capable of producing any value, it should be implemented.