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

solid.stream.Merge Maven / Gradle / Ivy

Go to download

Solid is an Android library, which provides lightweight data streams and immutable+parcelable collections.

There is a newer version: 1.0.14
Show newest version
package solid.stream;

import java.util.Iterator;

public class Merge extends Stream {

    private Iterable source;
    private Iterable with;

    public Merge(Iterable source, Iterable with) {
        this.source = source;
        this.with = with;
    }

    @Override
    public Iterator iterator() {
        return new ReadOnlyIterator() {
            Iterator sourceI = source.iterator();
            Iterator withI = with.iterator();

            @Override
            public boolean hasNext() {
                return sourceI.hasNext() || withI.hasNext();
            }

            @Override
            public T next() {
                return sourceI.hasNext() ? sourceI.next() : withI.next();
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy