src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java
@SuppressWarnings("unchecked")
    public void forEachWhile(NonThrowingPredicate<? super T> consumer) {
        Object[] a = head;
        final int c = capacity;
        while (a != null) {
            for (int i = 0; i < c; i++) {
                Object o = a[i];
                if (o == null) {
                    break;
                }
                if (consumer.test((T)o)) {
                    return;
                }
            }
            a = (Object[])a[c];
        }
    }
@SuppressWarnings("unchecked")
    public void forEachWhile(NonThrowingPredicate<? super T> consumer) {
        Object[] a = head;
        final int c = capacity;
        while (a != null) {
            for (int i = 0; i < c; i++) {
                Object o = a[i];
                if (o == null) {
                    break;
                }
                if (consumer.test((T)o)) {
                    return;
                }
            }
            a = (Object[])a[c];
        }
    }
Loops over all elements of the array until a null element is encountered or
the given predicate returns true.
@param consumer the consumer of values that returns true if the forEach should terminate