Create the same empty collection

@return Collection
501504
public function createClone($data = []) {
		$collection = static::factory($data, $this->getModel(), $this->getPrimary());
		
		if ($this->hasDatagate()) {
			$collection->setDatagate($this->getDatagate());
		}
		
		if ($this->hasLocator()) {
			$collection->setLocator($this->getLocator());
		}
		
		return $collection;
	}
1168855
public function clear()
    {
        $this->emitOnChange(__METHOD__);
        $items = &$this->items();
        if (count($this->listeners('item.remove'))) {
            foreach ($items as $item) {
                $this->emit('item.remove', [$item, $this]);
            }
        }

        // It's not mistake that $items never used after assigning empty array.
        // Yep, it really clears the collection.
        $items = [];
        $this->endEmitOnChange(__METHOD__);
        return $this;
    }
373228
protected function rawCollection(): Collection
    {
        $conn = $this->connPool->getConnection();
        $database = $conn->defaultDatabase;

        return $conn->getRawConnection()->$database->{$this->collection};
    }
291138
def create(name, dry_run, verbose, query=None, parent=None):
    """"""
    if parent is not None:
        parent = Collection.query.filter_by(name=parent).one().id
    collection = Collection(name=name, dbquery=query, parent_id=parent)
    db.session.add(collection)
    if verbose:
        click.secho('New collection: {0}'.format(collection))
1144224
public function values()
    {
        $count       = $this->count()->toNative();
        $valuesArray = new \SplFixedArray($count);

        foreach ($this->items as $key => $item) {
            $valuesArray->offsetSet($key, $item->getValue());
        }

        return new Collection($valuesArray);
    }
692364
public function getEqualFromCollection(\Phunc\Collection $collection)
    {
        $new_collection = clone $this;
        $new_collection->cleanCollection();

        /** @var CollectionInstanceInterface $instance */
        foreach ($this->getCollection() as $instance) {
            /** @var CollectionInstanceInterface $same */
            foreach ($collection as $same) {
                if ($this->isEqual($same)) {
                    $new_collection->add($this->getEqual($same));
                }
            }
        }
        return $new_collection;
    }
1035194
public function createFromCollection(Collection $collection)
    {
        $this->operator = new CollectionOperator($collection, $this->request);
        $this->prepare();

        return $this;
    }
1220257
public function copy(): Collection
    {
        $items = $this->items;
        $resolver = $this->resolver;

        return new static($items, $resolver);
    }
935408
public function saveCollection()
    {
        // Get dependencies
        $collectionMapper = ($this->container->dataMapper)('CollectionMapper');
        $toolbox = $this->container->toolbox;

        // Create collection object and populate
        $collection = $collectionMapper->make();
        $collection->id = $this->request->getParsedBodyParam('id');
        $collection->title = $this->request->getParsedBodyParam('title');
        $collection->slug = $toolbox->cleanUrl($this->request->getParsedBodyParam('slug'));
        $collection->definition = $this->request->getParsedBodyParam('definition');

        $collection = $collectionMapper->save($collection);

        return $this->redirect('adminCollections');
    }
930041
private function createCollections()
    {
        $collections = $this->mongo->listCollections();

        $collectionsCreated = false;
        foreach ($collections as $collection) {
            /* @var $collection CollectionInfo */
            if ($collection->getName() == self::ADB_STATS_DAILY) {
                $collectionsCreated = true;
                break;
            }
        }

        if (!$collectionsCreated) {

            // create collections
            $this->mongo->createCollection(self::ADB_STATS_DAILY);
            $this->mongo->createCollection(self::ADB_STATS_MONTHLY);
            $this->mongo->createCollection(self::ADB_DIMS);

            // ensure indexes
            $this->mongo->createIndex(self::ADB_STATS_DAILY, new CompoundIndex('entityTsEntry', ['entity', 'ref', 'ts'], true, true));
            $this->mongo->createIndex(self::ADB_STATS_DAILY,
                new CompoundIndex('entityTsAttrEntry', ['entity', 'ts', 'attributes.name', 'attributes.value'], false, false));

            $this->mongo->createIndex(self::ADB_STATS_MONTHLY, new CompoundIndex('entityMonthEntry', ['entity', 'ref', 'ts'], true, true));
            $this->mongo->createIndex(self::ADB_STATS_MONTHLY,
                new CompoundIndex('entityMonthAttrEntry', ['entity', 'ts', 'attributes.name', 'attributes.value'], false, false));

            $this->mongo->createIndex(self::ADB_DIMS, new CompoundIndex('dimension', ['name', 'value', 'entity', 'ts'], true, true));

            $this->mongo->createIndex(self::ADB_DIMS, new CompoundIndex('dimension_entity', ['entity', 'ts'], true));
        }
    }
443124
public function copy()
    {
        $list = [];
        foreach ($this->getIterator() as $key => $value) {
            $list[$key] = \is_object($value) ? clone $value : $value;
        }

        return $this->createFrom($list);
    }
723991
protected function populateModuleCollection()
    {
        $this->modules = new Collection;

        foreach ($this->moduleClasses as $moduleClass) {

            $instance = $this->instantiateClass($moduleClass);

            if ($instance instanceof ModuleGeneratorInterface) {
                $this->storeModulesForGenerator($instance);
                continue;
            }

            // instance is a module
            $this->storeModule($instance);
        }

        return $this;
    }
1209304
public function collections()
    {
        $uri = $this->uri->withPath($this->uri->getPath() . ':listCollectionIds');
        $value = $this->client->post($uri, null);
        $collections = [];

        foreach ($value['collectionIds'] as $id) {
            $collections[] = $this->collection($id);
        }

        return $collections;
    }
121658
protected function createCollectionLoader()
    {
        $loader = $this->createCollectionLoaderFromTrait();

        $mainMenu = filter_input(INPUT_GET, 'main_menu', FILTER_SANITIZE_STRING);
        if ($mainMenu) {
            $loader->setCallback(function (&$obj) use ($mainMenu) {
                if (!$obj['main_menu']) {
                    $obj['main_menu'] = $mainMenu;
                }
            });
        }

        return $loader;
    }
153025
public static function get($params = array())
	{
		$object = new static;
		$data   = $object->request('GET', $object->getUrl(), $params);
		$data   = $object->stripResponseData($data);

		// Initialise a collection
		$collection = self::newCollection();

		if (isset($data[0]) && is_array($data[0])) {
			// This should be a collection
			$collection->setItems($data);
		}

		return $collection;
	}
881842
public function even(): ArrayCollection
    {
        $items = [];
        $pos = 0;

        foreach ($this->items as $key => $value) {
            if ($pos % 2 === 0) {
                $items[$key] = $value;
            }
            $pos++;
        }

        return new static($items);
    }
75208
public static function make(): CheckerCollection
    {
        $checkerCollection = new CheckerCollection();

        do_action(self::REGISTER_HOOK, $checkerCollection);
        do_action(self::BOOT_HOOK, $checkerCollection);

        return $checkerCollection;
    }