toIterable

@param mixed $iterable

@return  iterable

@since  3.5
321202
public static function toIterable($iterable): iterable
    {
        if (is_iterable($iterable)) {
            return $iterable;
        }

        if (is_object($iterable)) {
            return get_object_vars($iterable);
        }

        return (array) $iterable;
    }
467058
public function withIterable(iterable $enumerators): self
    {
        $clone = clone $this;
        foreach ($enumerators as $enumerator) {
            $clone->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
        }
        return $clone;
    }
1040216
public static @Nonnull <T> Iterable<T> enumerationToIterable(@Nullable Enumeration<T> enumeration) {
        if (enumeration == null) {
            return Collections.emptyList();
        }

        return () -> new Iterator<T>() {
            @Override
            public boolean hasNext() {
                return enumeration.hasMoreElements();
            }

            @Override
            public T next() {
                return enumeration.nextElement();
            }
        };
    }
652785
protected function buildOrderBy(Iterator $iterator): Iterator
    {
        if ([] === $this->order_by) {
            return $iterator;
        }

        $compare = function (array $record_a, array $record_b): int {
            foreach ($this->order_by as $callable) {
                if (0 !== ($cmp = $callable($record_a, $record_b))) {
                    return $cmp;
                }
            }

            return $cmp ?? 0;
        };

        $iterator = new ArrayIterator(iterator_to_array($iterator));
        $iterator->uasort($compare);

        return $iterator;
    }
1197214
public function getIterator() : \Traversable
    {
        foreach ($this->objects as $hash => $object) {
            yield $object => $this->data[$hash];
        }
    }
829629
public static <T> C.List<T> toList(Iterable<? extends T> iterable) {
        if (iterable instanceof Collection) {
            return toList((Collection<T>) iterable);
        }
        ListBuilder<T> lb = new ListBuilder<T>(10);
        for (T t : iterable) {
            lb.add(t);
        }
        return lb.toList();
    }
8019
public static function toKeysArray(ResultIterator $iterator)
    {
        $keys = array();
        foreach ($iterator as $result) {
            $keys[] = $result->getKey();
            
        }
        return $keys;
    }
265444
public static <T> CloseableIterable<T> distinct(final CloseableIterable<T> iterable) {
        return wrap(Iterables2.distinct(iterable), iterable);
    }
326837
public function each(callable $iterator) : Collection
    {
        foreach ($this as $k => $v) {
            call_user_func($iterator, $v, $k, $this);
        }
        return $this;
    }
1084570
public static <T> List<T> toList(TypedIterable<T> iterable) {
        List<T> result = new ArrayList<>();
        for (T item : iterable) {
            result.add(item);
        }
        return result;
    }
622066
public Iterable<T> filter(final Iterable<T> iterable) {
        return new Iterable<T>() {

            @Override
            public Iterator<T> iterator() {
                return filter(iterable.iterator());
            }
        };
    }
833364
public static <T> CloseableIterable<T> fromIterable(Iterable<T> iterable) {
        requireNonNull(iterable);
        if (iterable instanceof CloseableIterable) return (CloseableIterable<T>) iterable;

        return new FluentCloseableIterable<T>() {
            @Override
            protected void doClose() {
                if (iterable instanceof AutoCloseable) {
                    try {
                        ((AutoCloseable) iterable).close();
                    } catch (RuntimeException re) {
                        throw re;
                    } catch (Exception e) {
                        throw new IllegalStateException(e);
                    }
                }
            }

            @Override
            protected Iterator<T> retrieveIterator() {
                return iterable.iterator();
            }
        };
    }
916496
@SuppressWarnings("unchecked")
    protected Iterable _transform(final Iterable iterable) {
        if (iterable == null) return null;
        if (iterable instanceof BeanIterable) return iterable;
        return new BeanIterable<>(iterable, this);
    }
1121990
public function getIterator() : iterable
    {
        foreach ($this->bufferedChanges as $change) {
            yield $change;
        }

        foreach ($this->unBufferedChanges ?? [] as $change) {
            $this->bufferedChanges[] = $change;

            yield $change;
        }

        $this->unBufferedChanges = null;
    }
87824
private function getIterator($value)
    {
        if ($value instanceof \Iterator) {

            return $value;
        }

        if (is_array($value)) {

            return new \ArrayIterator($value);
        }

        return new \ArrayIterator([$value]);
    }
492677
public function getIterator(): \Generator
    {
        foreach ($this->sourceIterable as $content) {
            try {
                yield $this->stream->write($content);
            } catch (\InvalidArgumentException $ex) {
                throw new \RuntimeException('The iterable generated values that are not writable', 0, $ex);
            }
        }
    }
897474
public function getIterator()
    {
        $data = $this->data;
        foreach ($this->data as $key => $val) {
            $data[$key] = $this->extractKey($key);
        }
        return new \ArrayIterator($data);
    }