An tierator that filter its element by a predicate pred.

Introduced properties

init defaultinit(my_iter: Iterator[OLD], pred: Fun1[E, Bool])

functional :: FilterIter :: defaultinit

protected fun pred=(pred: Fun1[E, Bool])

functional :: FilterIter :: pred=

Redefined properties

redef type SELF: FilterIter[E]

functional $ FilterIter :: SELF

Type of this instance, automatically specialized in every class
redef init init

functional $ FilterIter :: init

redef fun item: nullable E

functional $ FilterIter :: item

The current item.
redef fun next

functional $ FilterIter :: next

Jump to the next item.

All properties

type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
init defaultinit(my_iter: Iterator[OLD], pred: Fun1[E, Bool])

functional :: FilterIter :: defaultinit

init init

core :: Object :: init

abstract fun item: E

core :: Iterator :: item

The current item.
abstract fun next

core :: Iterator :: next

Jump to the next item.
protected fun pred=(pred: Fun1[E, Bool])

functional :: FilterIter :: pred=

package_diagram functional::FilterIter FilterIter

Ancestors

interface Iterator[E: nullable Object]

core :: Iterator

Iterators generate a series of elements, one at a time.
interface Object

core :: Object

The root of the class hierarchy.

Class definitions

functional $ FilterIter
# An tierator that filter its element by a predicate `pred`.
class FilterIter[E]
        super FunIter[E,nullable E]
        var pred: Fun1[E, Bool]

        redef init
        do
                if is_ok and not pred.call(my_iter.item) then next
        end

        redef fun item
        do
                assert is_ok
                return my_iter.item
        end

        redef fun next
        do
                loop
                        my_iter.next
                        if not is_ok then
                                break
                        end
                        var x = my_iter.item
                        if pred.call(x) then
                                break
                        end
                end
        end
end
lib/functional/iter_extras.nit:279,1--308,3