Adds items from another stream to the end of the current stream.

@param with an {@link Iterable} that should be used to emit items after items in the current stream ran out.
@return a new stream that contains items from both streams.
490918
public Stream<T> merge(final Iterable<? extends T> with) {
        return new Stream<T>() {
            @Override
            public Iterator<T> iterator() {
                return new ReadOnlyIterator<T>() {

                    Iterator<T> iterator = Stream.this.iterator();
                    Iterator<? extends T> withIterator = with.iterator();

                    @Override
                    public boolean hasNext() {
                        return iterator.hasNext() || withIterator.hasNext();
                    }

                    @Override
                    public T next() {
                        return iterator.hasNext() ? iterator.next() : withIterator.next();
                    }
                };
            }
        };
    }
351917
private static <T> List<T> join(List<T> list1, List<T> list2) {
        return list1.appendList(list2);
    }
451344
public ListBuffer<A> append(A x) {
        Assert.checkNonNull(x);
        if (shared) copy();
        List<A> newLast = List.of(x);
        if (last != null) {
            last.tail = newLast;
            last = newLast;
        } else {
            elems = last = newLast;
        }
        count++;
        return this;
    }
72243
@Override
	public final void coGroup(Iterable<IN1> first, Iterable<IN2> second, Collector<OUT> out) throws Exception {
		streamer.streamBufferWithGroups(first.iterator(), second.iterator(), out);
	}
470938
public static <T> Stream<T> parallelConcatt(final Collection<? extends Iterator<? extends T>> c, final int readThreadNum) {
        return parallelConcatt(c, readThreadNum, calculateQueueSize(c.size()));
    }
715081
public static <T> Stream<T> of(final Supplier<Collection<? extends T>> supplier) {
        final Iterator<T> iter = new ObjIteratorEx<T>() {
            private Iterator<? extends T> iterator = null;

            @Override
            public boolean hasNext() {
                if (iterator == null) {
                    init();
                }

                return iterator.hasNext();
            }

            @Override
            public T next() {
                if (iterator == null) {
                    init();
                }

                return iterator.next();
            }

            private void init() {
                final Collection<? extends T> c = supplier.get();

                if (N.isNullOrEmpty(c)) {
                    iterator = ObjIterator.empty();
                } else {
                    iterator = c.iterator();
                }
            }
        };

        return of(iter);
    }
594220
public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) {
      return concat(Arrays.asList(a, b));
    }
616297
public Gather<T> concat(Iterable<? extends T> iterable) {
		return from(Iterables.concat(each(), iterable));
	}
658919
public static <A, B, C, R> Stream<R> zip(final Collection<? extends A> a, final Collection<? extends B> b, final Collection<? extends C> c,
            final TriFunction<? super A, ? super B, ? super C, R> zipFunction) {
        return zip(a.iterator(), b.iterator(), c.iterator(), zipFunction);
    }
387873
public static <T> boolean addAll(Collection<T> self, Iterator<T> items) {
        boolean changed = false;
        while (items.hasNext()) {
            T next =  items.next();
            if (self.add(next)) changed = true;
        }
        return changed;
    }
724270
public void concat(AbstractLinkedList<? extends E, ? extends T> other) {
        if (other.isEmpty()) {
            return;
        }

        if (isEmpty()) {
            head = other.head;
            last = other.last;
        } else {
            T otherHead = other.head;
            last.setNext(otherHead);
            otherHead.setPrev(last);
            last = other.last;
        }
        size += other.size;
        other.clear();
    }
510391
public static <T> Stream<Map.Entry<Integer, T>> enumerate(Stream<T> stream) {
        Iterator<Map.Entry<Integer, T>> iterator = new Iterator<Map.Entry<Integer, T>>() {
            private int counter = 0;
            
            private final Iterator<T> internalIterator = stream.iterator();
            
            /** {@inheritDoc} */
            @Override
            public boolean hasNext() {
                return internalIterator.hasNext();
            }
            
            /** {@inheritDoc} */
            @Override
            public Map.Entry<Integer, T> next() {
                return new AbstractMap.SimpleImmutableEntry<>(counter++, internalIterator.next());
            }

            /** {@inheritDoc} */
            @Override
            public void remove() {
                throw new UnsupportedOperationException("This is a read-only iterator, remove operation is not supported.");
            }
        };
        return stream(iterator, stream.isParallel());
    }
996943
public static <T> T[] addAllTo(Iterable<T> source, T[] target) {
        int i = 0;
        for (T item : source) {
            target[i++] = item;
        }
        return target;
    }
616678
public static <T> Stream<T> parallelConcatt(final Collection<? extends Iterator<? extends T>> c) {
        return parallelConcatt(c, DEFAULT_READING_THREAD_NUM);
    }
725381
public static <T> Stream<T> parallelConcat(final Collection<? extends Stream<? extends T>> c) {
        return parallelConcat(c, DEFAULT_READING_THREAD_NUM);
    }
1119385
public ListBuilder<T> add(T... items) {
        list.addAll(Arrays.asList(items));
        return this;
    }
480715
public static void append(Appendable out, Object object) throws IOException {
        if (object instanceof String) {
            out.append((String) object);
        } else if (object instanceof Object[]) {
            out.append(toArrayString((Object[]) object));
        } else if (object instanceof Map) {
            out.append(toMapString((Map) object));
        } else if (object instanceof Collection) {
            out.append(toListString((Collection) object));
        } else if (object instanceof Writable) {
            Writable writable = (Writable) object;
            Writer stringWriter = new StringBuilderWriter();
            writable.writeTo(stringWriter);
            out.append(stringWriter.toString());
        } else if (object instanceof InputStream || object instanceof Reader) {
            // Copy stream to stream
            Reader reader;
            if (object instanceof InputStream) {
                reader = new InputStreamReader((InputStream) object);
            } else {
                reader = (Reader) object;
            }
            char[] chars = new char[8192];
            int i;
            while ((i = reader.read(chars)) != -1) {
                for (int j = 0; j < i; j++) {
                    out.append(chars[j]);
                }
            }
            reader.close();
        } else {
            out.append(toString(object));
        }
    }