SkipIterator.java 1001 Bytes
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.granite.security.user.util;

import java.util.Iterator;

public class SkipIterator<T>
implements Iterator<T> {
    private final Iterator<T> iterator;
    private int pos;

    public static <T> SkipIterator<T> create(Iterator<T> iterator) {
        return new SkipIterator<T>(iterator);
    }

    public SkipIterator(Iterator<T> iterator) {
        this.iterator = iterator;
    }

    public long skip(long skipNum) {
        long c = 0;
        while (c < skipNum && this.iterator.hasNext()) {
            this.iterator.next();
            ++c;
            ++this.pos;
        }
        return c;
    }

    public long getPosition() {
        return this.pos;
    }

    @Override
    public boolean hasNext() {
        return this.iterator.hasNext();
    }

    @Override
    public T next() {
        ++this.pos;
        return this.iterator.next();
    }

    @Override
    public void remove() {
        this.iterator.remove();
    }
}