public function withInserted(int $idx, Element $el): self
    {
        if (count($this->_elements) < $idx || $idx < 0) {
            throw new \OutOfBoundsException("Index $idx is out of bounds.");
        }
        $obj = clone $this;
        array_splice($obj->_elements, $idx, 0, [$el]);
        return $obj;
    }
public function withInserted(int $idx, Element $el): self
    {
        if (count($this->_elements) < $idx || $idx < 0) {
            throw new \OutOfBoundsException("Index $idx is out of bounds.");
        }
        $obj = clone $this;
        array_splice($obj->_elements, $idx, 0, [$el]);
        return $obj;
    }
public function withInserted ( int $ idx , Element $ el ) : self { if ( count ( $ this -> _elements ) < $ idx || $ idx < 0 ) { throw new \ OutOfBoundsException ( "Index $idx is out of bounds." ) ; } $ obj = clone $ this ; array_splice ( $ obj -> _elements , $ idx , 0 , [ $ el ] ) ; return $ obj ; }
Get self with an element inserted before the given index.

@param int $idx Element index
@param Element $el New element to insert into the structure
@throws \OutOfBoundsException
@return self
Get self with an element inserted before the given index .