Remaps a collection.

@param  array $collection
@param  array $map
@return array
424389
public static function remapCollection(array $collection, array $map, $createMode = true)
    {
        $results = array();

        foreach ($collection as $item) {
            $results[] = self::remap($item, $map, $createMode);
        }

        return $results;
    }
462025
public function mergeWith(Collection $collection): Collection
    {
        $calledClass = get_called_class();

        if ($collection instanceof $calledClass) {
            foreach ($collection as $key => $object) {
                $this[$key] = $object;
            }
        } else {
            throw new \InvalidArgumentException(sprintf('%s::mergeWith() method require an same type of Collection.', get_class($this)));
        }

        return $this;
    }
1274251
public function map(array $collection, Closure $iterator)
    {
        foreach ($collection as $key => $node)
        {
            $collection[$key] = $iterator($key, $node);
        }

        return $collection;
    }
150677
public function createMapping(array $map)
    {
        try {
            $elasticclient = $this->client->getClient();
            $response = $elasticclient->indices()->create($map);
            return  $response['acknowledged'];
        } catch (\Exception $ex) {
            return $ex->getMessage();
        }
    }
373200
public function transform($map)
    {
        if (is_callable($map)) {
            return $map($this);
        }

        $data = [];
        foreach ($map as $key) {
            $data[$key] = $this->{$key};
        }

        return $data;
    }
1157099
public function pluck(string $key): ArrayCollection
    {
        return $this->map(function ($value) use ($key) {
            return $value[$key] ?? null;
        });
    }
586765
public function mapCollections(array $data): array
    {
        $collections = [];

        foreach ($data as $dataItem) {
            $collectionId = (int) $dataItem['id'];
            $locale = $dataItem['locale'];

            if (!isset($collections[$collectionId])) {
                $collections[$collectionId] = [
                    'id' => $collectionId,
                    'status' => (int) $dataItem['status'],
                    'offset' => (int) $dataItem['start'],
                    'limit' => $dataItem['length'] !== null ? (int) $dataItem['length'] : null,
                    'isTranslatable' => (bool) $dataItem['translatable'],
                    'mainLocale' => $dataItem['main_locale'],
                    'alwaysAvailable' => (bool) $dataItem['always_available'],
                ];
            }

            $collections[$collectionId]['availableLocales'][] = $locale;
        }

        return array_values(
            array_map(
                static function (array $collectionData): Collection {
                    sort($collectionData['availableLocales']);

                    return Collection::fromArray($collectionData);
                },
                $collections
            )
        );
    }
1295829
protected function serializeEmbeddedCollection(MapperInterface $mapper, array $collection)
    {
        $data = array();
        foreach ($collection as $object) {
            $data[] = $mapper->serialize($object);
        }

        return $data;
    }
386442
public function intersect(Collection $collection)
    {
        $array1 = $this->items;
        $array2 = $collection->toArray();

        $this->items = array_uintersect($array1, $array2, function($val1, $val2) {
            return strcmp($val1['slug'], $val2['slug']);
        });

        return $this;
    }
94645
public function exchangeArray($collection)
    {
        if (!is_array($collection) && !($collection instanceof Traversable)) {
            throw new Exception\InvalidArgumentException(
                sprintf(
                    'Expected argument "array" or "Traversable"; "%s" given',
                    gettype($collection) . (is_object($collection) ? '(' . get_class($collection) . ')' : '')
                )
            );
        }

        if ($collection instanceof Traversable) {
            $collection = ArrayUtils::iteratorToArray($collection);
        }

        foreach ($collection as $key => $value) {
            $this->set($key, $value);
        }
    }
1194822
public function insert(array $collection)
    {
        foreach ($collection as $key => $inputs) {
            $collection[$key] = $this->purifyInputs($inputs);
        }

        return $this->model->insert($collection);
    }
1287673
public static function universalSet($collection, $key, $value)
    {
        $set_object = function ($object, $key, $value) {
            $newObject = clone $object;
            $newObject->$key = $value;

            return $newObject;
        };
        $set_array = function ($array, $key, $value) {
            $array[$key] = $value;

            return $array;
        };
        $setter = __::isObject($collection) ? $set_object : $set_array;

        return call_user_func_array($setter, [$collection, $key, $value]);
    }
1240916
public function keys($collection=null) {
    list($collection) = self::_wrapArgs(func_get_args(), 1);
    
    if(!is_object($collection) && !is_array($collection)) throw new Exception('Invalid object');
    
    return self::_wrap(array_keys((array) $collection));
  }
86163
protected void remapData(int[][] mapping) throws IOException {
    if (!closed) {
      // remap and merge keys
      String[] newKeyList = new String[mapping.length];
      // process mapping for functions?
      HashMap<MtasDataCollector<?, ?>, MtasDataCollector<?, ?>> map = new HashMap<>();
      int[] newSourceNumberList = new int[mapping.length];
      int[] newErrorNumber = new int[mapping.length];
      @SuppressWarnings("unchecked")
      HashMap<String, Integer>[] newErrorList = (HashMap<String, Integer>[]) new HashMap<?, ?>[mapping.length];
      for (int i = 0; i < mapping.length; i++) {
        newKeyList[i] = keyList[mapping[i][0]];
        newSourceNumberList[i] = sourceNumberList[mapping[i][0]];
        for (int j = 0; j < mapping[i].length; j++) {
          if (j == 0) {
            newErrorNumber[i] = errorNumber[mapping[i][j]];
            newErrorList[i] = errorList[mapping[i][j]];
          } else {
            newErrorNumber[i] += errorNumber[mapping[i][j]];
            for (Entry<String, Integer> entry : errorList[mapping[i][j]]
                .entrySet()) {
              if (newErrorList[i].containsKey(entry.getKey())) {
                newErrorList[i].put(entry.getKey(),
                    newErrorList[i].get(entry.getKey()) + entry.getValue());
              } else {
                newErrorList[i].put(entry.getKey(), entry.getValue());
              }
            }
          }
        }
      }
      if (hasSub) {
        newSubCollectorListNextLevel = new MtasDataCollector<?, ?>[mapping.length];
        for (int i = 0; i < mapping.length; i++) {
          for (int j = 0; j < mapping[i].length; j++) {
            if (j == 0 || newSubCollectorListNextLevel[i] == null) {
              newSubCollectorListNextLevel[i] = subCollectorListNextLevel[mapping[i][j]];
            } else {
              newSubCollectorListNextLevel[i]
                  .merge(subCollectorListNextLevel[mapping[i][j]], map, false);
            }
          }
        }
        subCollectorListNextLevel = newSubCollectorListNextLevel;
      }
      keyList = newKeyList;
      sourceNumberList = newSourceNumberList;
      errorNumber = newErrorNumber;
      errorList = newErrorList;
      size = keyList.length;
      position = 0;
    } else {
      throw new IOException("already closed");
    }
  }
228780
public function mapParams(array $map, $params = null)
    {
        if (!isset($params)) {
            $params = $this->params;
        }

        $mapped = array();

        foreach ($params as $key => $value) {
            if (isset($map[$key]) && is_string($map[$key])) {
                gplcart_array_set($mapped, $map[$key], $value);
            }
        }

        return $mapped;
    }
1325412
public function update(array $collection){
        foreach($collection as $key => $value){
            $this->collection[$key] = $value;
        }
        return $this;
    }
1114259
protected function getMappedKey($map, $key)
    {
        if (is_array($map)) {
            if (array_key_exists($key, $map)) {
                return $map[$key];
            } else {
                return $key;
            }
        }
        return $key;
    }