// Replace will convert all items in the given list to TimestampedEntries
// before attempting the replace operation. The replace operation will
// delete the contents of the ExpirationCache `c`.
332809
func (c *ExpirationCache) Replace(list []interface{}, resourceVersion string) error {
	items := make(map[string]interface{}, len(list))
	ts := c.clock.Now()
	for _, item := range list {
		key, err := c.keyFunc(item)
		if err != nil {
			return KeyError{item, err}
		}
		items[key] = &TimestampedEntry{item, ts}
	}
	c.expirationLock.Lock()
	defer c.expirationLock.Unlock()
	c.cacheStorage.Replace(items, resourceVersion)
	return nil
}
51935
func (md *MDCacheStandard) Replace(newRmd ImmutableRootMetadata,
	oldBID kbfsmd.BranchID) error {
	md.lock.Lock()
	defer md.lock.Unlock()
	oldKey := mdCacheKey{newRmd.TlfID(), newRmd.Revision(), oldBID}
	newKey := mdCacheKey{newRmd.TlfID(), newRmd.Revision(), newRmd.BID()}
	// TODO: implement our own LRU where we can replace the old data
	// without affecting the LRU status.
	md.lru.Remove(oldKey)
	md.lru.Add(newKey, newRmd)
	return nil
}
908892
func (p *Partition) replaceFileSet(fs *FileSet) {
	p.fileSet.Release()
	p.fileSet = fs
}
84149
func (c *MemoryCacher) Put(key, val string, expire int64) error {
	c.lock.Lock()
	defer c.lock.Unlock()

	c.items[key] = &MemoryItem{
		val:     val,
		created: time.Now().Unix(),
		expire:  expire,
	}
	return nil
}
1322994
func ReplaceLeft(s, old, new string) string {
	old_len, new_len, i, n := len(old), len(new), 0, 0
	for ; i < len(s) && strings.HasPrefix(s[i:], old); n += 1 {
		i += old_len
	}

	// simple optimization
	if n == 0 {
		return s
	}

	// allocating space for the new string
	newLen := n*new_len + len(s[i:])
	replacement := make([]byte, newLen, newLen)

	j := 0
	for ; j < n*new_len; j += new_len {
		copy(replacement[j:j+new_len], new)
	}

	copy(replacement[j:], s[i:])
	return string(replacement)
}
1163272
func (db *Database) replaceMarks(in string) string {
	var buffer bytes.Buffer
	for _, runeValue := range in {
		if runeValue == '?' {
			buffer.WriteString("$")
			buffer.WriteString(strconv.Itoa(db.varCount))
			db.varCount++
		} else {
			buffer.WriteRune(runeValue)
		}
	}
	return buffer.String()
}
954421
func (h Handler) Replace(cmd common.SetRequest) error {
	_, err := h.doRequest(cmd, common.RequestReplace)
	return err
}
57653
func (r *Replacer) Replace(s []byte) []byte {
	return r.r.Replace(s)
}
191127
func replacePrefix(s string, args ...string) string {
	if len(args) != 2 {
		return s
	}
	if strings.HasPrefix(s, args[0]) {
		return strings.Replace(s, args[0], args[1], 1)
	}
	return s
}
1250441
func (c *Cache) remove(itmID string) {
	ci, has := c.cache[itmID]
	if !has {
		return
	}
	if c.maxEntries != UnlimitedCaching {
		c.lruIdx.Remove(c.lruRefs[itmID])
		delete(c.lruRefs, itmID)
	}
	if c.ttl > 0 {
		c.ttlIdx.Remove(c.ttlRefs[itmID])
		delete(c.ttlRefs, itmID)
	}
	c.remItemFromGroups(ci.itemID, ci.groupIDs)
	delete(c.cache, ci.itemID)
	if c.onEvicted != nil {
		c.onEvicted(ci.itemID, ci.value)
	}
}
762401
func (r Replacer) Replace(ctx context.Context, state request.Request, rr *dnstest.Recorder, s string) string {
	for _, placeholder := range r.labels {
		if strings.Contains(s, placeholder) {
			s = strings.Replace(s, placeholder, r.valueFunc(state, rr, placeholder), -1)
		}
	}

	// Metadata label replacements. Scan for {/ and search for next }, replace that metadata label with
	// any meta data that is available.
	b := strings.Builder{}
	for strings.Contains(s, labelReplacer) {
		idxStart := strings.Index(s, labelReplacer)
		endOffset := idxStart + len(labelReplacer)
		idxEnd := strings.Index(s[endOffset:], "}")
		if idxEnd > -1 {
			label := s[idxStart+2 : endOffset+idxEnd]

			fm := metadata.ValueFunc(ctx, label)
			replacement := EmptyValue
			if fm != nil {
				replacement = fm()
			}

			b.WriteString(s[:idxStart])
			b.WriteString(replacement)
			s = s[endOffset+idxEnd+1:]
		} else {
			break
		}
	}

	b.WriteString(s)
	return b.String()
}
738183
func replaceWithLetters(str string) string {
	if str == "" {
		return str
	}
	bytestr := []byte(str)
	for i := 0; i < len(bytestr); i++ {
		if bytestr[i] == questionmark {
			bytestr[i] = byte(randLetter())
		}
	}

	return string(bytestr)
}
1185218
func (v *TreeVertex) replace(id string, r *TreeVertex) {
	if v.Id == id {
		v.Descendants = r.Descendants
		return
	}
	for _, u := range v.Descendants {
		u.replace(id, r)
	}
}
208040
func (m *ModifyRequest) Replace(attrType string, attrVals []string) {
	m.ReplaceAttributes = append(m.ReplaceAttributes, PartialAttribute{Type: attrType, Vals: attrVals})
}
1179385
func (c Context) Replace(input, find, replacement string) string {
	return strings.Replace(input, find, replacement, -1)
}
726346
func Replace(from, to string) error {
	if err := os.RemoveAll(to); err != nil {
		return err
	}
	if err := os.Rename(from, to); err != nil {
		return err
	}

	// Directory was renamed; sync parent dir to persist rename.
	pdir, err := OpenDir(filepath.Dir(to))
	if err != nil {
		return err
	}

	if err = pdir.Sync(); err != nil {
		pdir.Close()
		return err
	}
	return pdir.Close()
}
26386
func (cp *CallbackProcessor) Replace(callbackName string, callback func(scope *Scope)) {
	log.Printf("[info] replacing callback `%v` from %v\n", callbackName, fileWithLineNum())
	cp.name = callbackName
	cp.processor = &callback
	cp.replace = true
	cp.parent.processors = append(cp.parent.processors, cp)
	cp.parent.reorder()
}