elk-util-parent/elk-util-collections/src/main/java/org/semanticweb/elk/util/collections/Operations.java
public static <T> Iterable<T> concat(
			final Iterable<? extends Iterable<? extends T>> inputs) {
		assert inputs != null;

		return new Iterable<T>() {

			@Override
			public Iterator<T> iterator() {

				return new Iterator<T>() {
					Iterator<? extends Iterable<? extends T>> outer = inputs
							.iterator();

					Iterator<? extends T> inner;
					boolean hasNext = advance();

					@Override
					public boolean hasNext() {
						return hasNext;
					}

					@Override
					public T next() {
						if (hasNext) {
							T result = inner.next();
							hasNext = advance();
							return result;
						}
						throw new NoSuchElementException();
					}

					@Override
					public void remove() {
						throw new UnsupportedOperationException();
					}

					boolean advance() {
						while (true) {
							if (inner != null && inner.hasNext())
								return true;

							if (outer.hasNext())
								inner = outer.next().iterator();
							else
								return false;
						}
					}
				};
			}
		};
	}
public static <T> Iterable<T> concat(
			final Iterable<? extends Iterable<? extends T>> inputs) {
		assert inputs != null;

		return new Iterable<T>() {

			@Override
			public Iterator<T> iterator() {

				return new Iterator<T>() {
					Iterator<? extends Iterable<? extends T>> outer = inputs
							.iterator();

					Iterator<? extends T> inner;
					boolean hasNext = advance();

					@Override
					public boolean hasNext() {
						return hasNext;
					}

					@Override
					public T next() {
						if (hasNext) {
							T result = inner.next();
							hasNext = advance();
							return result;
						}
						throw new NoSuchElementException();
					}

					@Override
					public void remove() {
						throw new UnsupportedOperationException();
					}

					boolean advance() {
						while (true) {
							if (inner != null && inner.hasNext())
								return true;

							if (outer.hasNext())
								inner = outer.next().iterator();
							else
								return false;
						}
					}
				};
			}
		};
	}
public static < T > Iterable < T > concat ( final Iterable < ? extends Iterable < ? extends T > > inputs ) { assert inputs != null ; return new Iterable < T > ( ) { @ Override public Iterator < T > iterator ( ) { return new Iterator < T > ( ) { Iterator < ? extends Iterable < ? extends T > > outer = inputs . iterator ( ) ; Iterator < ? extends T > inner ; boolean hasNext = advance ( ) ; @ Override public boolean hasNext ( ) { return hasNext ; } @ Override public T next ( ) { if ( hasNext ) { T result = inner . next ( ) ; hasNext = advance ( ) ; return result ; } throw new NoSuchElementException ( ) ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( ) ; } boolean advance ( ) { while ( true ) { if ( inner != null && inner . hasNext ( ) ) return true ; if ( outer . hasNext ( ) ) inner = outer . next ( ) . iterator ( ) ; else return false ; } } } ; } } ; }
Concatenates several {@link Iterable}s into one

@param inputs
the {@link Iterable} of {@link Iterable}s to be concatenated
@return {@link Iterable} consisting of all elements found in input
{@link Iterable}s
Concatenates several { @link Iterable } s into one