class_name FilterIterator extends Iterator

var iterator: Iterator
var predicate: Callable

func _init(iterator: Iterator, predicate: Callable) -> void:
    self.iterator = iterator
    self.predicate = predicate

func next() -> Option:
    var value = iterator.next()
    while value.is_some() and not predicate.call(value.unwrap()):
        value = iterator.next()
    return value
