Add Or Replace old query.

@param int    $index
@param string $stringSql
502408
public function addOrReplace($index, $stringSql)
    {
        if (!$stringSql) {
            return;
        }
        $sql = null;
        if ($this->offsetExists($index)) {
            $sql = $this->offsetGet($index);
            $sql->setSql($stringSql);
        } else {
            $sql = new Sql($stringSql);
            $this->add($sql);
        }

        return $sql;
    }
965845
function (index, count) {
    var newItems = Array.prototype.slice.call(arguments, 2),
    oldItems     = this.source.splice.apply(this.source, arguments);

    this._updateInfo();

    // DEPRECATED
    this.emit("replace", newItems, oldItems, index);
    this.emit("update", { insert: newItems, remove: oldItems });
  }
882386
public function insert($substring, $index) {
		if ($index <= 0) {
			return $this->prepend($substring);
		}

		if ($index > $this->length()) {
			return $this->append($substring);
		}

		$start = mb_substr($this->string, 0, $index, $this->encoding);
		$end = mb_substr($this->string, $index, $this->length(), $this->encoding);
		return new Text($start . $substring . $end);
	}
306152
protected function cacheKey(string $sql, array $values = null, string $index = null):string{
		return hash($this->cachekey_hash_algo, serialize([$sql, $values, $index]));
	}
135963
public function add($index, $newval) // [\SplDoublyLinkedList]
	{
		$first = $index === 0;
		$last  = $index === $this->size;
		
		if($first)
		{
			$this->unshift($newval);
		}
		else if($last)
		{
			$this->push($newval);
		}
		else if($this->offsetExists($index))
		{
			$this->moveToOffset($index - 1);
			
			$prev = $this->worker;
			
			$item = new Item($newval, $prev->next);
			
			$prev->next = $item;
			
			++$this->size;
			
			if
			(
				   (null !== $this->current_key)
				&& ($index <= $this->current_key)
			)
			{
				++$this->current_key;
			}
		}
		else
		{
			throw new OutOfRangeException('Offset invalid or out of range');
		}
	}
436830
public static function at($string, $index)
    {
        if (self::length($string) >= ($index + 1)) {
            return $string[$index];
        }

        exception(StringOutIndexException::class);
    }
1003893
public function addQuery($query, array $indexes)
    {
        if (empty($indexes)) {
            throw new EmptyIndexException('Try to search with empty indexes');
        }

        $this->sphinx->addQuery($query, implode(' ', $indexes));
    }
621634
protected function _update_batch($table, $values, $index)
	{
		$ids = array();
		foreach ($values as $key => $val)
		{
			$ids[] = $val[$index];

			foreach (array_keys($val) as $field)
			{
				if ($field !== $index)
				{
					$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
				}
			}
		}

		$cases = '';
		foreach ($final as $k => $v)
		{
			$cases .= $k.' = CASE '."\n";

			foreach ($v as $row)
			{
				$cases .= $row."\n";
			}

			$cases .= 'ELSE '.$k.' END, ';
		}

		$this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE);

		return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
	}
539747
public function transAlterIndex($table, $index, $schema)
    {
        $this->transInitTable($table);
        $this->schemaUpdateTransaction[$table]['alteredIndexes'][$index] = $schema;
    }
557828
protected function applyDefaultColumns($index)
    {
        $column = $this->loadColumnSchema([
            'Field' => 'id',
            'Type' => 'bigint',
        ]);
        $index->columns[$column->name] = $column;
        $index->primaryKey = 'id';
    }
85750
public function addRule($index, $method = null, ...$params)
    {
        $this->rules[$index] = [$method, $params];
        return $this;
    }
40598
public void addFreq(int index, int freq) {
        switch (index) {
            case 11:
                this.end += freq;
                allFreq += freq;
                break;
            case 12:
                this.end += freq;
                this.begin += freq;
                allFreq += freq;
                break;
            case 44:
                this.split += freq;
                allFreq += freq;
                break;
        }
    }
222727
public function addIndex($index, $after=null) {

        // Detect duplicates first
        if ($this->getIndex($index->getName())) {
            throw new coding_exception('Duplicate index '.$index->getName().' specified in table '.$this->getName());
        }

        // Make sure there are no keys with the index column specs because they would collide.
        $newfields = $index->getFields();
        $allkeys = $this->getKeys();
        foreach ($allkeys as $key) {
            $fields = $key->getFields();
            if ($fields === $newfields) {
                throw new coding_exception('Key '.$key->getName().' collides with index'.$index->getName().' specified in table '.$this->getName());
            }
        }

        // Calculate the previous and next indexes
        $previndex = null;
        $nextindex = null;

        if (!$after) {
            $allindexes = $this->getIndexes();
            if (!empty($allindexes)) {
                end($allindexes);
                $previndex = $allindexes[key($allindexes)];
            }
        } else {
            $previndex = $this->getIndex($after);
        }
        if ($previndex && $previndex->getNext()) {
            $nextindex = $this->getIndex($previndex->getNext());
        }

        // Set current index previous and next attributes
        if ($previndex) {
            $index->setPrevious($previndex->getName());
            $previndex->setNext($index->getName());
        }
        if ($nextindex) {
            $index->setNext($nextindex->getName());
            $nextindex->setPrevious($index->getName());
        }

        // Some more attributes
        $index->setLoaded(true);
        $index->setChanged(true);
        // Add the new index
        $this->indexes[] = $index;
        // Reorder the indexes
        $this->orderIndexes($this->indexes);
        // Recalculate the hash
        $this->calculateHash(true);
        // We have one new index, so the table has changed
        $this->setChanged(true);
    }
760827
function _string_shift(&$string, $index = 1)
    {
        $substr = substr($string, 0, $index);
        $string = substr($string, $index);
        return $substr;
    }
120733
public static String insert(String haystack, String needle, int index) {
		StringBuffer val = new StringBuffer(haystack);
		val.insert(index, needle);
		return val.toString();
	}
1127038
public void registerIndexQuery(long index, Runnable query) {
    // Add a query to be run once the session's index reaches the given index.
    List<Runnable> queries = this.indexQueries.computeIfAbsent(index, v -> new LinkedList<>());
    queries.add(query);
  }
117318
public function replaceChildAtBy($index, AbstractClassContent $contentSet)
    {
        $index = (isset($index) && is_int($index)) ? $index : false;
        if (is_bool($index)) {
            throw new BBException(__METHOD__.' index  parameter must be an integer');
        }
        $newContentsetArr = array();

        foreach ($this->getData() as $key => $content) {
            $contentToAdd = ($key == $index) ? $contentSet : $content;
            $newContentsetArr[] = $contentToAdd;
        }

        $this->clear();
        foreach ($newContentsetArr as $key => $content) {
            if ($content instanceof AbstractClassContent) {
                $this->push($content);
            }
        }

        return true;
    }