Gera um lista completa de compras a partir de um iterator
@param Iterator $iterator
188759
private function generateListByIterator(Iterator $iterator)
    {
        $resultado = array();
        foreach ($iterator as $compra) {
            $resultado[] = $this->preencherCompra($compra);
        }

        return $resultado;
    }
797082
public static <T> Iterator<T> getSortedIterator (Iterator<T> itr, Comparator<T> comparator)
    {
        SortableArrayList<T> list = new SortableArrayList<T>();
        CollectionUtil.addAll(list, itr);
        list.sort(comparator);
        return getUnmodifiableIterator(list);
    }
351369
private static function RemoveIterator( $iter, $index )
	{
		$pos = 1;

		/**
		 * @var XPathItem $item
		 */
		foreach ( $iter as $item )
		{
		    if ( $index != $pos )
			   yield $item;
		    $pos++;
		}
	}
912592
private function traversalDir(RecursiveArrayIterator $iterator)
    {
        $key = '';
        while ($iterator->valid()) {
            if ($iterator->hasChildren()) {
                $this->traversalDir($iterator->getChildren());
            } else {
                if ($iterator->key() == 'key' && ($iterator->current() != '/')) {
                    $this->dirs[] = $key = $iterator->current();
                }

                if ($iterator->key() == 'value') {
                    $this->values[$key] = $iterator->current();
                }
            }
            $iterator->next();
        }
        return $this->dirs;
    }
236663
public function getIterator(): Iterator
    {
        $map = $this->map;
        foreach ($map as $ordinal => $value) {
            yield ($this->enumeration)::byOrdinal($ordinal) => $value;
        }
    }
820997
public static function OneOrMore( $iter )
	{
		$iter = $iter->CreateBufferedIterator();
		/**
		 * @var XPath2NodeIterator $probe
		 */
		$probe = $iter->CloneInstance();
		if ( ! $probe->MoveNext() )
		    throw XPath2Exception::withErrorCode( "FORG0004", Resources::FORG0004 );

		return $iter;
	}
601033
public static function groupBy($collection = null, $iterator = null)
    {
        $result = array();
        $collection = (array) $collection;
        foreach ($collection as $k => $item) {
            if (is_object($iterator) && is_callable($iterator)) {
                $key = $iterator($item, $k);
            } elseif (is_object($item)) {
                $key = $item->$iterator;
            } elseif (is_array($item)) {
                $key = $item[$iterator];
            }
            
            if (!array_key_exists($key, $result)) {
                $result[$key] = array();
            }
            $result[$key][$k] = $item;
        }
        return $result;
    }
1023773
public static <T> List<T> list(boolean isLinked, Iterator<T> iter) {
		final List<T> list = list(isLinked);
		if (null != iter) {
			while (iter.hasNext()) {
				list.add(iter.next());
			}
		}
		return list;
	}
369819
protected function iterateFormErrors($iterator): array
    {
        $errors = [];
        foreach ($iterator as $error) {
            if ($error instanceof FormError) {
                $errors[] = $error->getMessage();
            } else {
                /* @var $error FormErrorIterator */
                $errors[$error->getForm()->getName()] = $this->iterateFormErrors($error);
            }
        }

        return $errors;
    }
554644
public function times($n=null, $iterator=null) {
    list($n, $iterator) = self::_wrapArgs(func_get_args(), 2);
    if(is_null($n)) $n = 0;
    
    for($i=0; $i<$n; $i++) $iterator($i);
    return self::_wrap(null);
  }
539110
public function find(callable $iterator)
    {
        foreach ($this as $k => $v) {
            if (call_user_func($iterator, $v, $k, $this)) {
                return $v;
            }
        }
        return null;
    }
1268346
public function unserialize($iterators)
    {
        parent::__construct(MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC);
        $this->_iterators = unserialize($iterators);
        foreach ($this->_iterators as $it) {
            $this->attachIterator($it);
        }
    }
918394
public function each(array $collection, Closure $iterator)
    {
        foreach ($collection as $key => $node)
        {
            $iterator($key, $node);
        }
    }
1152094
public static function adapter(\Traversable $iterator)
    {
        if ($iterator instanceof IIterator) {
            return $iterator;
        } elseif ($iterator instanceof IGenerator) {
            return new IGeneratorAdapter($iterator);
        } elseif ($iterator instanceof \ArrayIterator) {
            return new ArrayIteratorAdapter($iterator);
        } elseif ($iterator instanceof \IteratorAggregate) {
            return static::adapter($iterator->getIterator());
        } else {
            return new IteratorAdapter($iterator);
        }
    }
180585
public function getIterator()
    {
        $iterator   = parent::getIterator();
        $content    = $this->getDependentContent();

        if ( $content )
        {
            $iterator->append( new ArrayIterator( array(
                'rootImage' => $content->leadImage,
                'rootText'  => $content->leadText,
            ) ) );
        }

        return $iterator;
    }
251844
protected function nextObject(\Iterator $iterator)
    {
        if ($iterator->valid()) {
            $object = $iterator->current();

            $iterator->next();

            return $object;
        }

        return false;
    }
1047525
public function buildFromIterator(Traversable $iterator)
    {
        $this->box->buildFromIterator($iterator, $this->pharComposer->getBase());
    }