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

org.aksw.commons.collections.cache.CountingIterator Maven / Gradle / Ivy

There is a newer version: 0.9.9
Show newest version
package org.aksw.commons.collections.cache;

import java.util.Iterator;

public class CountingIterator
    extends IteratorDecorator
{
    protected long numItems;

    public CountingIterator(Iterator delegate) {
        this(delegate, 0l);
    }

    public CountingIterator(Iterator delegate, long numItems) {
        super(delegate);
        this.numItems = numItems;//new AtomicLong(numItems);
    }

    public long getNumItems() {
        return numItems; //.get();
    }

    @Override
    public T next() {
        T result = super.next();
        ++numItems;
        //numItems.incrementAndGet();
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy