public function swapIndex($index, $newIndex) : bool
    {
        if ($newIndex < 0 || $newIndex > sizeof($this->elements)) {
            return false;
        }

        $object = $this->elements[$index];
        $newObject = $this->elements[$newIndex];
        $this->elements[$newIndex] = $object;
        $this->elements[$index] = $newObject;

        return true;
    }