All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.marksman.collectionviews.VectorIterator Maven / Gradle / Ivy

There is a newer version: 1.2.3
Show newest version
package dev.marksman.collectionviews;

import java.util.Iterator;
import java.util.NoSuchElementException;

final class VectorIterator implements Iterator {
    private final Vector underlying;
    private int index;

    VectorIterator(Vector underlying) {
        this.underlying = underlying;
        index = 0;
    }

    @Override
    public boolean hasNext() {
        return index < underlying.size();
    }

    @Override
    public A next() {
        if (index >= underlying.size()) {
            throw new NoSuchElementException();
        }
        A result = underlying.unsafeGet(index);
        index += 1;
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy