Add item at the specified position

@param Item $item
@param int $position
If no position specified or int is higher to the higher bound,
append the item, for prepending set 0
166058
public function addAt(Item $item, $position = null)
    {
        if (0 === $position) {
            array_unshift($this->items, $item);
        } else if (null === $position) {
            $this->items[] = $item;
        } else if (count($this->items) <= $position) {
            $this->items[] = $item;
        } else {
            array_splice($this->items, $position, 0, [$item]);
        }

        $this->isUpdated = true;

        return $this;
    }
1043036
public function set($index, $item)
    {
        $this->offsetSet($index, $this->parser->text($item));
    }
564568
public void onItemBind(int position, T item) {
        if (onItemBind != null) {
            variableId = VAR_INVALID;
            layoutRes = LAYOUT_NONE;
            onItemBind.onItemBind(this, position, item);
            if (variableId == VAR_INVALID) {
                throw new IllegalStateException("variableId not set in onItemBind()");
            }
            if (layoutRes == LAYOUT_NONE) {
                throw new IllegalStateException("layoutRes not set in onItemBind()");
            }
        }
    }
530302
public function offsetSet($offset, $item)
	{
		if ($offset === null)
		{
			$this->_data[] = $item;
			$this->_total = count($this->_data);
		}
		else
		{
			$this->_data[$offset] = $item;
		}
	}
1057126
public function addItem(Item $item)
	{
		$item->source = $this->link;

		$this->items[] = $item;

		return $this;
	}
844895
public function push($item)
    {
        if (!is_array($item)) {
            $this->items = array_merge($this->items, [$item]);
            return $this;
        }
        $this->items = array_merge($this->items, $item);
        return $this;
    }
124621
protected function add_item_label($item, $element) {
        if (strlen($item->label) && ($this->mode == self::MODE_EDIT || $this->mode == self::MODE_VIEW_TEMPLATE)) {
            $name = $element->getLabel();
            $name = '('.format_string($item->label).') '.$name;
            $element->setLabel($name);
        }
    }
1196562
private function addItem(Item $item)
    {
        $em = $this->getDoctrine()->getManager();
        $em->persist($item);
        $em->flush();

        return $this->redirect($this->generateUrl(
            'item_show',
            ['id' => $item->getId(), 'name' => $item->getUrlName()]
        ));
    }
486668
public void add(T item) {
        hasElements = true;
        navigator = emptyItemIndex;
        items[emptyItemIndex] = item;
        if (emptyItemIndex == size - 1) {
            wasFullAtleastOnce = true;
        }
        emptyItemIndex = (emptyItemIndex + 1) % size;
    }
1355322
protected function append(array $item)
    {
        if (!$this->isEnabled()) {
            $this->enable();
        }

        $this->getContainer()->append($item);
    }
462802
void add(T item) {
    int i = nextIndex.getAndIncrement() % data.length();
    data.set(i, item);
  }
1264634
public function setItem(Item $item)
    {
        if ($this->item !== $item) {
            $this->item = $item->setType($this);
        }

        return $this;
    }
713384
public function addItemToReplacementData( $itemId )
    {
        if ( !isset( $this->replacementData[$itemId] ) )
        {
            $this->replacementData[$itemId] = 0;
        }
        ++$this->replacementData[$itemId];
    }
678068
public function process(DOMElement $node, Item $item)
    {
        foreach ($this->keys as $key) {
            $item->setExtra($key, $this->getValue($node, $key));
        }
    }
997924
public function add(string $place, ItemMenu $itemMenu)
    {
        $arg = get_object_vars($itemMenu);

        if (array_key_exists('show', $arg) && ! $arg['show']) {
            return $this;
        }

        $this->location = $place;
        $this->arg = $arg;
        $this->sort = $arg['sort'];

        $this->item = [
            'location' => $this->location,
            'arg'      => $this->arg,
            'sort'     => $this->sort,
        ];

        $this->container[$this->arg['slug']] = $this->item;

        return $this;
    }
1006940
public function add($item)
    {
        $allItems = $this->getAll();
        if (is_array($item)) {
            $allItems = array_merge($allItems, $item);
        } else {
            $allItems[] = $item;
        }

        $this->setAll($allItems);
    }
1170352
public function addItem(OrderingItem $item)
    {
        if (!$this->items->contains($item)) {
            $item->setQuestion($this);
            $this->items->add($item);
        }
    }