// SetRange sets the data with new value from offset.
357463
func (db *DB) SetRange(key []byte, offset int, value []byte) (int64, error) {
	if len(value) == 0 {
		return 0, nil
	}

	if err := checkKeySize(key); err != nil {
		return 0, err
	} else if len(value)+offset > MaxValueSize {
		return 0, errValueSize
	}

	key = db.encodeKVKey(key)

	t := db.kvBatch

	t.Lock()
	defer t.Unlock()

	oldValue, err := db.bucket.Get(key)
	if err != nil {
		return 0, err
	}

	extra := offset + len(value) - len(oldValue)
	if extra > 0 {
		oldValue = append(oldValue, make([]byte, extra)...)
	}

	copy(oldValue[offset:], value)

	t.Put(key, oldValue)

	if err := t.Commit(); err != nil {
		return 0, err
	}

	return int64(len(oldValue)), nil
}
215718
func (v *Vector) SetRange(start, end int, e Equaler) {
	switch l := end - start; {
	case l == 0:
		if !v.Relaxed && (start < v.min.pos || start >= v.max.pos) {
			panic(ErrOutOfRange)
		}
		return
	case l == 1:
		v.Set(start, e)
		return
	case l < 0:
		panic(ErrInvertedRange)
	}

	if !v.Relaxed && (start < v.min.pos || end > v.max.pos || start == v.max.pos) {
		panic(ErrOutOfRange)
	}

	// Do fast path complete vector replacement if possible.
	if start <= v.min.pos && v.max.pos <= end {
		v.t = llrb.Tree{}
		*v.min = position{pos: start, val: e}
		v.t.Insert(v.min)
		v.max.pos = end
		v.t.Insert(v.max)
		return
	}

	// Handle cases where the given range is entirely outside the vector.
	switch {
	case start >= v.max.pos:
		oldEnd := v.max.pos
		v.max.pos = end
		if start != oldEnd {
			prev := v.t.Floor(query(oldEnd)).(*position)
			if !prev.val.Equal(v.Zero) {
				v.t.Insert(&position{pos: oldEnd, val: v.Zero})
			}
		}
		last := v.t.Floor(query(start)).(*position)
		if !e.Equal(last.val) {
			v.t.Insert(&position{pos: start, val: e})
		}
		return
	case end < v.min.pos:
		if v.min.val.Equal(v.Zero) {
			v.min.pos = end
		} else {
			v.min = &position{pos: end, val: v.Zero}
			v.t.Insert(v.min)
		}
		fallthrough
	case end == v.min.pos:
		if e.Equal(v.min.val) {
			v.min.pos = start
		} else {
			v.min = &position{pos: start, val: e}
			v.t.Insert(v.min)
		}
		return
	}

	// Handle cases where the given range
	last := v.t.Floor(query(end)).(*position)
	deleteRangeInclusive(&v.t, start, end)
	switch {
	// is entirely within the existing vector;
	case v.min.pos < start && end <= v.max.pos:
		prev := v.t.Floor(query(start)).(*position)
		if !e.Equal(prev.val) {
			v.t.Insert(&position{pos: start, val: e})
		}
		if last.val == nil {
			v.t.Insert(v.max)
		} else if !e.Equal(last.val) {
			v.t.Insert(&position{pos: end, val: last.val})
		}

	// hangs over the left end and the right end is in the vector; or
	case start <= v.min.pos:
		lastVal := last.val
		*v.min = position{pos: start, val: e}
		v.t.Insert(v.min)

		if !e.Equal(lastVal) {
			v.t.Insert(&position{pos: end, val: lastVal})
		}

	// hangs over the right end and the left end is in the vector.
	case end > v.max.pos:
		v.max.pos = end
		v.t.Insert(v.max)

		prev := v.t.Floor(query(start)).(*position)
		if e.Equal(prev.val) {
			return
		}
		if last.val == nil || !e.Equal(last.val) {
			v.t.Insert(&position{pos: start, val: e})
		}

	default:
		panic("step: unexpected case")
	}
}
507673
func (h *Handle) SetAnyInRange(start, end uint64, serial bool) (uint64, error) {
	if end < start || end >= h.bits {
		return invalidPos, fmt.Errorf("invalid bit range [%d, %d]", start, end)
	}
	if h.Unselected() == 0 {
		return invalidPos, ErrNoBitAvailable
	}
	return h.set(0, start, end, true, false, serial)
}
1236502
func (s *AssessmentRunFilter) SetDurationRange(v *DurationRange) *AssessmentRunFilter {
	s.DurationRange = v
	return s
}
1301880
func (s *HyperParameterSpecification) SetRange(v *ParameterRange) *HyperParameterSpecification {
	s.Range = v
	return s
}
1109661
func (r *Range) Set(value string) error {
	newRange, err := ParseRange(value)
	if err != nil {
		return err
	}
	*r = *newRange
	return nil
}
703494
func (s *DescribeOfferingOutput) SetRegion(v string) *DescribeOfferingOutput {
	s.Region = &v
	return s
}
186550
func (s *CreateStackInput) SetRegion(v string) *CreateStackInput {
	s.Region = &v
	return s
}
664437
func (a *PrintToPDFArgs) SetPageRanges(pageRanges string) *PrintToPDFArgs {
	a.PageRanges = &pageRanges
	return a
}
173674
func (s *S3Resource) SetKeyRange(v *KeyRange) *S3Resource {
	s.KeyRange = v
	return s
}
854991
func inRange(x, a, b token.Position) bool {
	if !util.PathEqual(x.Filename, a.Filename) || !util.PathEqual(x.Filename, b.Filename) {
		return false
	}
	return x.Offset >= a.Offset && x.Offset <= b.Offset
}
681878
func (l *LiteBackend) PutRange(ctx context.Context, items []backend.Item) error {
	for i := range items {
		if items[i].Key == nil {
			return trace.BadParameter("missing parameter key in item %v", i)
		}
	}
	err := l.inTransaction(ctx, func(tx *sql.Tx) error {
		return l.putRangeInTransaction(ctx, tx, items, false)
	})
	if err != nil {
		return trace.Wrap(err)
	}
	return nil
}
1284885
func (s *DynamoDBAction) SetRangeKeyField(v string) *DynamoDBAction {
	s.RangeKeyField = &v
	return s
}
685443
func (s *ObjectAttributeRange) SetRange(v *TypedAttributeValueRange) *ObjectAttributeRange {
	s.Range = v
	return s
}
140646
func (s *Set) Range(from, to interface{}) Iterator {
	return s.skiplist.Range(from, to)
}
1335535
func NewRange(from int, to int) (*Range, error) {
	return (&rangeBuilder{}).from(from, nil).to(to, nil).Range()
}
828860
func (s *TypedLinkAttributeRange) SetRange(v *TypedAttributeValueRange) *TypedLinkAttributeRange {
	s.Range = v
	return s
}