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

com.annimon.stream.operator.ObjDistinct Maven / Gradle / Ivy

package com.annimon.stream.operator;

import com.annimon.stream.iterator.LsaExtIterator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class ObjDistinct extends LsaExtIterator {

    private final Iterator iterator;
    private final Set set;

    public ObjDistinct(Iterator iterator) {
        this.iterator = iterator;
        set = new HashSet();
    }

    @Override
    protected void nextIteration() {
        while (hasNext = iterator.hasNext()) {
            next = iterator.next();
            if (set.add(next)) {
                return;
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy