Apply mapping.

@param iterable $iterable
@return iterable
540585
protected function apply(iterable $iterable): iterable
    {
        return Pipeline::with($iterable)
            ->mapKeys(function($_, $info) {
                $field = is_array($info) ? ($info['field'] ?? null) : $info;
                $newField = $this->map[$field] ?? ($this->dynamic ? $field : null);

                return isset($newField) && is_array($info) ? ['field' => $newField] + $info : $newField;
            })
            ->filter(function($_, $info) {
                return $info !== null;
            });
    }
1304412
private function iterableToArray(iterable $iterable): array
    {
        $result = [];

        foreach ($iterable as $key => $value) {
            $result[$key] = $value instanceof Generator ? $this->iterableToArray($value) : $value;
        }

        return $result;
    }
622066
public Iterable<T> filter(final Iterable<T> iterable) {
        return new Iterable<T>() {

            @Override
            public Iterator<T> iterator() {
                return filter(iterable.iterator());
            }
        };
    }
891145
public function map(callable $callable)
    {
        $keys = array_keys($this->items);
        $results = array_map($callable, $this->items, $keys);

        return new self($results);
    }
177261
public function map(callable $callback): Map
    {
        $apply = function($pair) use ($callback) {
            return $callback($pair->key, $pair->value);
        };

        return new self(array_map($apply, $this->pairs));
    }
386263
public function each($callback)
    {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('Mapping function is not callable!');
        }

        array_walk($this->attributes, $callback);

        return $this;
    }
361476
public function createSitemap(Iterator $iterator)
    {
        $groupName = $this->randomHash();
        $paths = new ArrayObject();
        $sitemap = new Sitemap();
        foreach ($iterator as $entry) {
            if ($sitemap->hasMaxUrlCount()) {
                $paths->append($this->writeSitemap($groupName, $sitemap));
                $sitemap = new Sitemap();
            }

            list($url, $lastmod, $changefreq, $priority) = $this->parseEntry($entry);
            $sitemap->add($url, $lastmod, $changefreq, $priority);
        }
        $paths->append($this->writeSitemap($groupName, $sitemap));

        if ($paths->count() > 1) {
            return $this->createSitemapIndex($paths->getIterator());
        }

        return $this->fileUrl($paths[0]);
    }
62273
public function each($collection=null, $iterator=null) {
    list($collection, $iterator) = self::_wrapArgs(func_get_args(), 2);
    
    if(is_null($collection)) return self::_wrap(null);
    
    $collection = (array) self::_collection($collection);
    if(count($collection) === 0) return self::_wrap(null);
    
    foreach($collection as $k=>$v) {
      call_user_func($iterator, $v, $k, $collection);
    }
    return self::_wrap(null);
  }
513802
public function map()
    {
        $args = func_get_args();
        $methods = array_shift($args);
        $methods = is_array($methods) ? $methods : explode(',', $methods);

        foreach ($methods as $method) {
            $method = strtoupper($method);
            $this->setRoute($method, $args);
        }
        return $this;
    }
964792
public function combineKeys(iterable $keys): self
    {
        if (count($keys) != count($this->items)) {
            $this->doThrow('Invalid input for combineKeys, number of items does not match.', $keys);
        }
        $collection = Factory::create();
        $this->rewind();
        foreach ($keys as $key) {
            $collection->set($key, $this->current());
            $this->next();
        }
        $this->rewind();

        return $collection;
    }
911090
@SuppressWarnings("unchecked")
  public static Iterator<Object> iterator(Object iterable) {
    Assert.state(isIterable(iterable.getClass()));
    return iterable.getClass().isArray() ? new ArrayIterator(iterable)
        : ((Iterable<Object>) iterable).iterator();
  }
132087
public function mapWithKeys(callable $callback): CollectionInterface
    {
        return $this->wrap(function (Iterator $data) use ($callback) {
            foreach ($data as $key => $value) {
                /** @var iterable $result */
                $result = $callback($value, $key);

                foreach ($result as $resultKey => $resultValue) {
                    yield $resultKey => $resultValue;
                }
            }
        });
    }
456736
public function append(iterable $values): self
    {
        foreach ($values as $value) {
            $this->add($value);
        }

        return $this;
    }
1198944
public static function create(iterable $iterable, $callable = null): ISeq
    {
        if ($callable !== null) {
            $callable = (new CallbackParser(InvalidArgumentException::class))->parseArrowFunction($callable);

            return new static(function () use ($iterable, $callable) {
                foreach ($iterable as $i) {
                    $item = $callable($i);

                    if (is_iterable($item)) {
                        yield from $item;
                    } else {
                        yield $item;
                    }
                }
            });
        }

        return new static($iterable);
    }
938982
public function zip(iterable $items): self
    {
        $collection = Factory::create($items);

        return $this->map(
            function ($value, $key, $index) use ($collection) {
                return [$value, $collection->atIndex($index)];
            }
        );
    }
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;
    }
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);
    }