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

com.davfx.ninio.http.UnionIterable Maven / Gradle / Ivy

There is a newer version: 1.0.99
Show newest version
package com.davfx.ninio.http;

import java.util.Iterator;

public final class UnionIterable implements Iterable {
	private final Iterable i;
	private final Iterable j;
	
	public UnionIterable(Iterable i, Iterable j) {
		this.i = i;
		this.j = j;
	}

	@Override
	public Iterator iterator() {
		final Iterator ii = i.iterator();
		final Iterator ji = j.iterator();
		return new Iterator() {
			@Override
			public boolean hasNext() {
				return ii.hasNext() || ji.hasNext();
			}
			@Override
			public T next() {
				if (ii.hasNext()) {
					return ii.next();
				}
				return ji.next();
			}
			@Override
			public void remove() {
				throw new UnsupportedOperationException();
			}
		};
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy