Replaces the value at a given index in the sequence with a new value.

@param int   $index
@param mixed $value

@return \PlanB\DS\Sequence

@throws \OutOfRangeException if the index is not in the range [0, size-1]
437445
public function set(int $index, $value): Sequence
    {
        $this->offsetSet($index, $value);

        return $this;
    }
114630
public function execute($value)
    {
        if (!is_array($value) || count($value) != 2) {
            throw new \Exception('Value for number range comparison should have to values');
        }

        $queryBuilder = $this->getQueryBuilder();

        if (!empty($value[0])) {
            $queryBuilder->andHaving(
                $queryBuilder->expr()->gte(
                    $this->getIndex(),
                    ":{$this->getIndexClean()}_1"
                )
            )
                ->setParameter(
                    ":{$this->getIndexClean()}_1",
                    (float) $value[0]
                );
        }

        if (!empty($value[1])) {
            $queryBuilder->andHaving(
                $queryBuilder->expr()->lte(
                    $this->getIndex(),
                    ":{$this->getIndexClean()}_2"
                )
            )
                ->setParameter(
                    ":{$this->getIndexClean()}_2",
                    (float) $value[1]
                );
        }
    }
512931
public void set(int index, double value) {
        checkIndex(index);

        IndexValue item = new IndexValue(index, 0);
        int valueIndex = Collections.binarySearch(values, item, comp);
        if (valueIndex >= 0 && value != 0d) {
            // Replace a currently existing item with a non zero value.
            values.get(valueIndex).value = value;
        } else if (value != 0d) {
            // Add a new cell item into this row.
            item.value = value;
            values.add((valueIndex + 1) * -1, item);
        } else if (valueIndex >= 0) {
            // Remove the value since it's now zero.
            values.remove(valueIndex);
        }
    }
657004
public V setValueAt(int index, V value) {
        index = (index << 1) + 1;
        V old = (V)mArray[index];
        mArray[index] = value;
        return old;
    }
1098368
public function add($index, $value): Utility
    {
        if (is_null($this->get($index))) {
            return $this->set($index, $value);
        }

        return $this;
    }
1123587
public function offsetSet($index, $newval) // [\ArrayAccess]
	{
		if($this->offsetExists($index))
		{
			$this->moveToOffset($index);
			
			$this->worker->data = $newval;
		}
		else if($index == '')
		{
			$this->push($newval);
		}
		else
		{
			throw new OutOfRangeException('Offset invalid or out of range');
		}
	}
374176
public function setIndex($index)
    {
        if ($index instanceof Index) {
            $index = $index->getName();
        }

        return $this->setParam('_index', $index);
    }
59055
public function set($index, $value): Utility
    {
        $newBag = $this->toArray();

        $newBag[$index] = $value;

        return new self($newBag);
    }
101057
public function update(Expression $value, Expression $index = null)
    {
        if ($this->value === $value && $this->index === $index) {
            return $this;
        }

        return new self($value, $index);
    }
944451
public function setIndex($index)
    {
        if (!is_int($index) || $index < 0) {
            throw new \InvalidArgumentException(sprintf('The value\'s index must be a positive integer, "%s" given', var_export($index, true)));
        }
        $this->index = $index;
        return $this;
    }
689521
public function replacePacket( $index, $packet )
	{
		if( !isset( $this->packetList[$index] ) )
			throw new OutOfRangeException( 'Invalid Packet Index.' );
		$this->packetList[$index]	= $packet;
	}
1051757
public function swap(int $index1, int $index2) : void
    {
        if ($index1 !== $index2) {
            $value = $this[$index1];
            $this[$index1] = $this[$index2];
            $this[$index2] = $value;
        }
    }
143553
public function setValue($value)
    {
        if (is_scalar($value)) {
            $this->value = new StringValue($value);
        } elseif (is_array($value)) {
            $this->value = new ArrayValue($value);
        } else {
            if (!$value instanceof ValueInterface) {
                throw new \Exception('The value must implement the ValueInterface.');
            } else {
                $this->value = $value;
            }
        }

        return $this;
    }
310485
public function setSelectedByValue($value)
    {
        $x = 0;
        foreach ($this->options as $idx => $data) {
            if ($value == $data) {
                $this->setSelectedIndex($x);

                return;
            }
            $x++;
        }

        $this->setSelectedIndex(-1);
    }
751284
public function removeAt($index) {
		
		if($this->_ReadOnly){
			throw new \RuntimeException(\get_called_class() . ' is read only');
		}
		
		if(!$this->offsetExists($index)){
			throw new \OutOfRangeException('$index is invalid');
		}
		
		\array_splice($this->_Arr, $index, 1);
		
		return $this;
		
	}
102621
public function insertAt(int $index, $value)
    {
        $array = $this->reindex()->asArray();

        Exception\InvalidArgumentException::verify(
            $index <= count($array),
            'The supplied index must not be greater than the amount of elements: expecting <= %s, %s given',
            count($array), $index
        );

        array_splice($array, $index, 0, [$value]);
        $this->updateElements(
            $this->scheme->createOrderedMap(
                $this->scheme->arrayIterator($array)
            )
        );
    }
85821
public function inRange($value, $offset)
    {
        $parts = \explode('-', $offset);

        return $parts[0] <= $value && $value <= $parts[1];
    }