// LSet updates an element in the list by its index.
4434
func (t *TxStructure) LSet(key []byte, index int64, value []byte) error {
	if t.readWriter == nil {
		return errWriteOnSnapshot
	}
	metaKey := t.encodeListMetaKey(key)
	meta, err := t.loadListMeta(metaKey)
	if err != nil || meta.IsEmpty() {
		return errors.Trace(err)
	}

	index = adjustIndex(index, meta.LIndex, meta.RIndex)

	if index >= meta.LIndex && index < meta.RIndex {
		return t.readWriter.Set(t.encodeListDataKey(key, index), value)
	}
	return errInvalidListIndex.GenWithStack("invalid list index %d", index)
}
708173
func (aa *AtomicArray) Set(idx int, node interface{}) error {
	// do not lock if not needed
	if idx < 0 || idx >= aa.length {
		return fmt.Errorf("index %d is larger than array size (%d)", idx, aa.length)
	}

	aa.mutex.Lock()
	aa.items[idx] = node
	aa.mutex.Unlock()
	return nil
}
859791
func (ia *Floats64Value) Set(s string) error {
	i, err := strconv.ParseFloat(s, 64)
	if err != nil {
		return err
	}
	*ia = append(*ia, i)
	return nil
}
458066
func (b *Bitset) Set(index, value int) bool {
	if index < b.size {
		b.setImpl(index, value)
		return true
	}
	return false
}
1277364
func (db *DB) LSet(key []byte, index int32, value []byte) error {
	if err := checkKeySize(key); err != nil {
		return err
	}

	var seq int32
	var headSeq int32
	var tailSeq int32
	//var size int32
	var err error
	t := db.listBatch
	t.Lock()
	defer t.Unlock()
	metaKey := db.lEncodeMetaKey(key)

	headSeq, tailSeq, _, err = db.lGetMeta(nil, metaKey)
	if err != nil {
		return err
	}

	if index >= 0 {
		seq = headSeq + index
	} else {
		seq = tailSeq + index + 1
	}
	if seq < headSeq || seq > tailSeq {
		return errListIndex
	}
	sk := db.lEncodeListKey(key, seq)
	t.Put(sk, value)
	err = t.Commit()
	return err
}
2949
func (opts *ListOpts) Set(value string) error {
	if opts.validator != nil {
		v, err := opts.validator(value)
		if err != nil {
			return err
		}
		value = v
	}
	*opts.values = append(*opts.values, value)
	return nil
}
820689
func (b *OpenBitSet) Set(index int64) {
	wordNum := b.expandingWordNum(index)
	bitmask := int64(1) << uint64(index&0x3f)
	b.bits[wordNum] |= bitmask
}
1107043
func (c Context) Set(z, x *Big) *Big {
	return c.Round(z.Copy(x))
}
622083
func (l *LogLevel) Set(s string) error {
	value, err := ParseLevel(s)
	if err != nil {
		return err
	}

	*l = value
	return nil
}
726901
func (c *Cache) Set(itmID string, value interface{}, grpIDs []string) {
	if c.maxEntries == DisabledCaching {
		return
	}
	c.Lock()
	defer c.Unlock()
	now := time.Now()
	if ci, ok := c.cache[itmID]; ok {
		ci.value = value
		c.remItemFromGroups(itmID, ci.groupIDs)
		ci.groupIDs = grpIDs
		c.addItemToGroups(itmID, grpIDs)
		if c.maxEntries != UnlimitedCaching { // update lru indexes
			c.lruIdx.MoveToFront(c.lruRefs[itmID])
		}
		if c.ttl > 0 && !c.staticTTL { // update ttl indexes
			ci.expiryTime = now.Add(c.ttl)
			c.ttlIdx.MoveToFront(c.ttlRefs[itmID])
		}
		return
	}
	ci := &cachedItem{itemID: itmID, value: value, groupIDs: grpIDs}
	c.cache[itmID] = ci
	c.addItemToGroups(itmID, grpIDs)
	if c.maxEntries != UnlimitedCaching {
		c.lruRefs[itmID] = c.lruIdx.PushFront(ci)
	}
	if c.ttl > 0 {
		ci.expiryTime = now.Add(c.ttl)
		c.ttlRefs[itmID] = c.ttlIdx.PushFront(ci)
	}
	if c.maxEntries != UnlimitedCaching {
		var lElm *list.Element
		if c.lruIdx.Len() > c.maxEntries {
			lElm = c.lruIdx.Back()
		}
		if lElm != nil {
			c.remove(lElm.Value.(*cachedItem).itemID)
		}
	}
}
898593
func (r *DB) set(data interface{}, allowed ...string) string {
	set := r.setMap(data, allowed...)
	return r.setImplode(", ", set)
}
529472
func (m *abstractPagedMutable) Set(index, value int64) {
	assert(index >= 0 && index < m.size)
	pageIndex := m.pageIndex(index)
	indexInPage := m.indexInPage(index)
	m.subMutables[pageIndex].Set(indexInPage, value)
}
1052847
func (i18 *I18Mem) Set(values map[string]string) {
	i18.muTranlsates.Lock()
	defer i18.muTranlsates.Unlock()
	for key, value := range values {
		i18.translates[key] = value
	}
}
487571
func (b *UpdateBuilder) Set(col interface{}, val interface{}) *UpdateBuilder {
	b.Update.Exprs = append(b.Update.Exprs, makeUpdateExpr(b.table, col, val))
	return b
}
1012909
func (b *UpdateBuilder) Set(columns ...string) *UpdateBuilder {
	for _, c := range columns {
		b.assignments = append(b.assignments, assignment{
			column: c,
			value:  param(c),
		})
	}

	return b
}
794121
func set(thread *Thread, fn *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
	var iterable Iterable
	if err := UnpackPositionalArgs("set", args, kwargs, 0, &iterable); err != nil {
		return nil, err
	}
	set := new(Set)
	if iterable != nil {
		iter := iterable.Iterate()
		defer iter.Done()
		var x Value
		for iter.Next(&x) {
			if err := set.Insert(x); err != nil {
				return nil, err
			}
		}
	}
	return set, nil
}
698244
func (c *Consistent) Set(elts []string) {
	c.Lock()
	defer c.Unlock()
	for k := range c.members {
		found := false
		for _, v := range elts {
			if k == v {
				found = true
				break
			}
		}
		if !found {
			c.remove(k)
		}
	}
	for _, v := range elts {
		_, exists := c.members[v]
		if exists {
			continue
		}
		c.add(v)
	}
}