Merges the items of the priority queue to one single list, paying attention to the priorities. The result is
written to the mergedItems property.
@return $this Implementing fluent interface.
500240
protected function mergeItems() {
        ksort($this->items);
        $this->mergedItems = array();
        foreach ($this->items as $items) {
            $this->mergedItems = array_merge($this->mergedItems, $items);
        }
        return $this;
    }
1180899
public function clearItems() {
		foreach ( $this->items as $item ) {
			$item->setElementGroup( null );
		}

		$this->items = [];
		$this->group->clearContent();

		return $this;
	}
696068
protected function createPriorityQueue()
    {
        $paths = $this->renderer->getPaths();

        if (!($paths instanceof PriorityQueue)) {
            $paths = new PriorityQueue($paths);

            $this->renderer->setPaths($paths);
        }

        return $this;
    }
483120
public function sort(): self
    {
        if (count($this->pairs) === count(array_count_values(array_column($this->pairs, 0)))) {
            return $this;
        }

        $pairs = array_merge(...array_values(array_reduce($this->pairs, [$this, 'reducePairs'], [])));
        if ($pairs === $this->pairs) {
            return $this;
        }

        $clone = clone $this;
        $clone->pairs = $pairs;

        return $clone;
    }
1106069
public function merge(ObjectCollectionInterface $collection)
    {
        $this->items = array_merge(
            $this->getItems(),
            $collection->getItems()
        );

        return $this;
    }
1325665
public function merge()
    {
        $array = $this->getResult();
        foreach ($array as $key => $value) {
            $value['name'] = $value['0'];
            $value['type'] = $value['1'];
            $value['key'] = $value['0'].' :';
            $value['value'] = '';
            unset($value['1']);
            unset($value['0']);
            $this->result[] = $value;
        }

        return $this->result;
    }
1154515
public function getIterator()
    {
        if (null === $this->queue) {
            $this->queue = new SplPriorityQueue();
            $this->queueOrder = 0;
            foreach (parent::getIterator() as $filter) {
                $this->queue->insert(
                    $filter,
                    array($this->priorities[$filter->getName()], $this->queueOrder--)
                );
            }
        }
        return clone $this->queue;
    }
111537
protected function _initItems()
    {
        parent::_initItems();

        foreach ($this->_items as $item) {
            $applyValue = $item->getLabel();
            if (($valuePos = array_search($applyValue, $this->currentFilterValue)) !== false) {
                $item->setIsSelected(true);
                $applyValue = $this->currentFilterValue;
                unset($applyValue[$valuePos]);
            } else {
                $applyValue = array_merge($this->currentFilterValue, [$applyValue]);
            }

            $item->setApplyFilterValue(array_values($applyValue));
        }

        return $this;
    }
910734
public function addItem(string $name, $item, int $priority = 50): self
    {
        if ($this->has($name)) {
            throw new DuplicateKeyException('Item with name '.$name.' already defined');
        }

        $this->items[$priority][$name] = $item;
        return $this;
    }
200310
public function shuffle()
    {
        $keys = array_keys($this->items);
        shuffle($keys);

        $new = [];
        foreach ($keys as $key) {
            $new[$key] = $this->items[$key];
        }

        $this->items = $new;

        return $this;
    }
147283
protected function applySorting()
    {
        $sortable = app('scaffold.sortable');
        $element = $sortable->element();
        $direction = $sortable->direction();

        if ($element && $direction) {
            if (is_string($element)) {
                $this->assembler()->sort($element, $direction);
            }
        }

        return $this;
    }
1004633
public function sort()
    {
        $index      = 0;
        $comparator = [$this->sorter, 'sort'];

        // add an index to provide stable sorting
        foreach ($this->items as &$item) {
            $item = [$index++, $item];
        }
        unset($item);

        uasort($this->items, function ($a, $b) use ($comparator) {
            $result = $comparator($a[1], $b[1]);

            // use the index to prevent undefined behaviour when comparator reports items are "equal"
            return $result === 0 ? $a[0] - $b[0] : $result;
        });

        // remove the index
        foreach ($this->items as &$item) {
            $item = $item[1];
        }
        unset($item);
    }
109585
public function order()
  {
    $this->stmt['order'] = array_unique(array_merge($this->stmt['order'], $this->buildArrayOfArgs(func_get_args())));
    return $this;
  }
194080
public function merge($data)
    {

        if ($data instanceof DedicatedPlayer) {
            $data = $data->toArray();
        }

        foreach ($data as $key => $value) {
            $key = lcfirst($key);
            $this->$key = $value;
        }

        return $this;
    }
1355740
public function addMiddleware($middleware, $priority = PriorityQueue::NORMAL)
    {
        if (is_array($middleware) && isset($middleware['priority'])) {
            $priority = $middleware['priority'];
        }

        $this->getMiddlewares()->insert($middleware, $priority);

        return $this;
    }
90894
public function merge( array ...$array_to_merge ) : self {

		foreach ( $array_to_merge as $arr ) {
			$items = array_replace_recursive( $this->getArrayCopy(), $arr );

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

		return $this;
	}
6417
public function detach($priority)
    {
        if ($this->started) {
            throw new RuntimeException('Unable during invoking.');
        }
        if (isset($this->queue[$priority])) {
            unset($this->queue[$priority]);
            $this->sortedQueue = null;
        }

        return $this;
    }