@ SafeVarargs public static < T > ElementIterator < T > compositeIterator ( Iterator < T > ... iterators ) { Require . nonNull ( iterators , "iterators" ) ; final Iterator < T > result ; if ( iterators . length == 0 ) { result = Collections . emptyIterator ( ) ; } else if ( iterators . length == 1 ) { if ( iterators [ 0 ] instanceof ElementIterator < ? > ) { return ( ElementIterator < T > ) iterators [ 0 ] ; } result = iterators [ 0 ] ; } else { result = new CompoundIterator <> ( iterators ) ; } return ElementIterator . wrap ( result ) ; }
Creates an iterator which subsequently iterates over all given iterators .