class_name SkipWhileIterator extends Iterator

var iterator: Iterator
var predicate: Callable
var _skipped: bool = false

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

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