Get a collection of entities

@param TableQuery $iterator
@param Table $definition
@return Collection
501750
public function collection(TableQueryIterator $iterator, Table $definition) : Collection
    {
        return Collection::from($iterator)
            ->map(function ($v) use ($definition) {
                return $this->entity($definition, $v);
            });
    }
1052999
public static <T, C extends Collection<? super T>> C toCollection(
        Iterator<T> iterator, C collection)
    {
        Objects.requireNonNull(iterator, "The iterator is null");
        Objects.requireNonNull(iterator, "The collection is null");
        while (iterator.hasNext())
        {
            collection.add(iterator.next());
        }
        return collection;
    }
326579
public function getIterator()
    {
        //Run the query
        $resp = $this->query->execute();

        //Return the documents as an ArrayIterator to satisfy the requirements
        //of the getIterator function.
        foreach ($resp->data as $document)
        {
            yield $document;
        }

        while ($resp->cursors->next) {
            //send a new request, resetting $resp
            $resp = $this->query->execute($resp->cursors->next);

            foreach ($resp->data as $document)
            {
                yield $document;
            }
        }
    }
918394
public function each(array $collection, Closure $iterator)
    {
        foreach ($collection as $key => $node)
        {
            $iterator($key, $node);
        }
    }
38078
public function collection( $collection, $transformer = null )
    {

        // Prevent error if include dont work
        // This only returns null
        if ( ! $collection ) {
            return $this->formatOutput([]);
        }

        // Check if we should call this function on another transformer
        if ( $transformer ) {
            return $transformer->collection( $collection );
        }

        // Build an data array to return
        $returnArray = [];
        foreach ($collection as $item) {
            $returnArray[] = $this->callTransform( $item );
        }

        // Format output
        return $this->formatOutput( $returnArray );
    }
969867
@Override
    public java.util.Iterator findEntitiesForGroup(IEntityGroup group) throws GroupsException {
        if (log.isDebugEnabled())
            log.debug(
                    DEBUG_CLASS_NAME
                            + ".findEntitiesForGroup(): retrieving entities for group "
                            + group);

        Collection entities = null;
        File f = getFile(group);
        if (f.isDirectory()) {
            entities = Collections.EMPTY_LIST;
        } else {
            entities = getEntitiesFromFile(f);
        }

        return entities.iterator();
    }
1065544
public function getIterator()
    {
        $tagsById       = $this->container->findTaggedServiceIds($this->tag);
        $taggedServices = array();
        foreach ($tagsById as $id => $tagDefinitions) {
            /* @var $id string */
            /* @var $tagDefinitions array(array(string=>string)) */
            foreach ($tagDefinitions as $tagDefinition) {
                /* @var $tagDefinition array(string=>string) */
                $taggedServices[] = new TaggedService($id, $tagDefinition);
            }
        }
        return new \ArrayIterator($taggedServices);
    }
867584
public function groupBy(array $collection, Closure $iterator)
    {
        $groups = [];

        foreach ($collection as $node)
        {
            $groups[$iterator($node)][] = $node;
        }

        sort($groups);

        return $groups;
    }
512661
@Override
    public Iterator<T> iterator() {
        Iterator<T> transformed = Iterators.transform(rows.iterator(), row -> {
            T value = mapper.map(row);
            mapper.mappingComplete();
            return value;
        });
        mapper.mappingComplete();
        return transformed;
    }
1332407
private function _iterator()
    {
        if(!isset($this->_iterator))
            $this->_iterator = $this->_resultSet()->getIterator();

        return $this->_iterator;
    }
1352542
static Iterator getIterator(Object agg) throws JMFSchemaViolationException {
    if (agg instanceof Collection) {
      return ((Collection)agg).iterator();
    }
    else if (agg.getClass().isArray()) {
      return new LiteIterator(agg);
    }
    else {
      throw new JMFSchemaViolationException(agg.getClass().getName());
    }
  }
197797
private function loadFromIterator(\Iterator $iterator)
    {
        $includedFiles = [];

        foreach ($iterator as $file) {
            if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) {
                continue;
            }

            $sourceFile = realpath($file->getPathName());
            require_once $sourceFile;
            $includedFiles[] = $sourceFile;
        }

        $fixtures = [];
        $declared = get_declared_classes();

        foreach ($declared as $className) {
            $reflClass = new \ReflectionClass($className);
            $sourceFile = $reflClass->getFileName();

            if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) {
                $fixture = new $className();
                $fixtures[] = $fixture;
                $this->addFixture($fixture);
            }
        }

        return $fixtures;
    }
642627
@Override
    public Iterable<T> findAll() {
        return inTransaction(new Callable<Iterable<T>>() {
            @Override
            public Iterable<T> call() throws Exception {
                CriteriaQuery<T> cq = entityManager.getCriteriaBuilder().createQuery(entity);
                Root<T> pet = cq.from(entity);
                cq.select(pet);
                return entityManager.createQuery(cq).getResultList();
            }
        });
    }
830892
def iterator(self):
        
        # FIXME: There is no dependency tracking; objects are iterated in
        #        random order.
        for ent_cls in list(self.__entity_set_map.keys()):
            for ent in self.__entity_set_map[ent_cls]:
                yield EntityState.get_state(ent)
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;
    }
1340152
public static function DistinctValuesWithCollation( $context, $iter, $collation )
	{
		if ( ! is_null( $collation ) && $collation != XmlReservedNs::collationCodepoint )
		{
			if ( ! setlocale( LC_COLLATE, $collation ) )
			{
				throw XPath2Exception::withErrorCodeAndParam( "FOCH0002", Resources::FOCH0002, $collation );
			}
		}

		return new NodeIterator( function() use( $iter, $collation ) { return ExtFuncs::DistinctIterator( $iter, $collation ); } );
	}
245873
public function thru(callable $iterator) : Collection
    {
        $temp = $this->toArray();
        $rslt = call_user_func($iterator, $temp);
        return new static($rslt);
    }