// markRange sets n consecutive bits starting at addr.
761615
func (b *bitmap) markRange(addr, n uintptr) {
	for end := addr + n; addr < end; {
		block, baddr := b.block(addr)
		for i := baddr; i < bmBlockRange && addr < end; i++ {
			block.mark(i)
			addr++
		}
	}
}
1203262
func (s *SourceInfo) SetRange(start, end int64) error {
	if start > end || start < 0 {
		return ErrInvalidArgument("start must be non-negative, and start must be at most end.")
	}
	// Note that 0 <= start <= end
	s.start, s.end = start, end
	return nil
}
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
}
1186394
func (dd *xlsxCellDataValidation) SetRange(f1, f2 int, t DataValidationType, o DataValidationOperator) error {
	formula1 := fmt.Sprintf("%d", f1)
	formula2 := fmt.Sprintf("%d", f2)

	switch o {
	case DataValidationOperatorBetween:
		if f1 > f2 {
			tmp := formula1
			formula1 = formula2
			formula2 = tmp
		}
	case DataValidationOperatorNotBetween:
		if f1 > f2 {
			tmp := formula1
			formula1 = formula2
			formula2 = tmp
		}
	}

	dd.Formula1 = formula1
	dd.Formula2 = formula2
	dd.Type = convDataValidationType(t)
	dd.Operator = convDataValidationOperatior(o)
	return nil
}
737762
func (s *HeadObjectInput) SetRange(v string) *HeadObjectInput {
	s.Range = &v
	return s
}
944007
func (f *NumericFacet) AddRange(name string, start, end float64) *NumericFacet {
	f.data.NumericRanges = append(f.data.NumericRanges, numericFacetRange{
		Name:  name,
		Start: start,
		End:   end,
	})
	return f
}
1007712
func Int64Range(min, max int64) gopter.Gen {
	if max < min {
		return Fail(reflect.TypeOf(int64(0)))
	}
	if max == math.MaxInt64 && min == math.MinInt64 { // Check for range overflow
		return func(genParams *gopter.GenParameters) *gopter.GenResult {
			return gopter.NewGenResult(genParams.NextInt64(), Int64Shrinker)
		}
	}

	rangeSize := uint64(max - min + 1)
	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		var nextResult = uint64(min) + (genParams.NextUint64() % rangeSize)
		genResult := gopter.NewGenResult(int64(nextResult), Int64Shrinker)
		genResult.Sieve = func(v interface{}) bool {
			return v.(int64) >= min && v.(int64) <= max
		}
		return genResult
	}
}
613836
func (mc *CCacheMetric) AddRange(prev uint32, itergens []chunk.IterGen) {
	if len(itergens) == 0 {
		return
	}

	if len(itergens) == 1 {
		mc.Add(prev, itergens[0])
		return
	}

	mc.Lock()
	defer mc.Unlock()

	// handle the first one
	itergen := itergens[0]
	ts := itergen.T0

	// if we add data that is older than chunks already cached,
	// we will have to sort the keys once we're done adding them
	sortKeys := len(mc.keys) > 0 && mc.keys[len(mc.keys)-1] > ts

	// add chunk if we don't have it yet (most likely)
	if _, ok := mc.chunks[ts]; !ok {

		// if previous chunk has not been passed we try to be smart and figure it out.
		// this is common in a scenario where a metric continuously gets queried
		// for a range that starts less than one chunkspan before now().
		res, ok := mc.seekDesc(ts - 1)
		if ok {
			if prev == 0 {
				prev = res
			} else if prev != res {
				log.Warnf("CCacheMetric AddRange: 'prev' param disagrees with seek: key = %s, prev = %d, seek = %d",
					mc.MKey.String(), prev, res)
			}
		}

		// if the previous chunk is cached, link it
		if prev != 0 && (ts-prev) != (itergens[1].T0-ts) {
			log.Warnf("CCacheMetric AddRange: Bad prev begin used: key = %s, prev = %d, itergens[0].Ts = %d, itergens[1].Ts = %d",
				mc.MKey.String(), prev, itergens[0].T0, itergens[1].T0)
			prev = 0
		} else if _, ok := mc.chunks[prev]; ok {
			mc.chunks[prev].Next = ts
		} else {
			prev = 0
		}

		mc.chunks[ts] = &CCacheChunk{
			Ts:    ts,
			Prev:  prev,
			Next:  itergens[1].T0,
			Itgen: itergen,
		}
		mc.keys = append(mc.keys, ts)
	} else {
		mc.chunks[ts].Next = itergens[1].T0
	}

	prev = ts

	// handle the 2nd until the last-but-one
	for i := 1; i < len(itergens)-1; i++ {
		itergen = itergens[i]
		ts = itergen.T0
		// Only append key if we didn't have this chunk already
		if _, ok := mc.chunks[ts]; !ok {
			mc.keys = append(mc.keys, ts)
		}

		// add chunk, potentially overwriting pre-existing chunk (unlikely)
		mc.chunks[ts] = &CCacheChunk{
			Ts:    ts,
			Prev:  prev,
			Next:  itergens[i+1].T0,
			Itgen: itergen,
		}

		prev = ts
	}

	// handle the last one
	itergen = itergens[len(itergens)-1]
	ts = itergen.T0

	// add chunk if we don't have it yet (most likely)
	if _, ok := mc.chunks[ts]; !ok {

		// if nextTs() can't figure out the end date it returns ts
		next := mc.nextTsCore(itergen, prev, 0)
		if next == ts {
			next = 0
		} else {
			// if the next chunk is cached, link in both directions
			if _, ok := mc.chunks[next]; ok {
				mc.chunks[next].Prev = ts
			} else {
				next = 0
			}
		}

		mc.chunks[ts] = &CCacheChunk{
			Ts:    ts,
			Prev:  prev,
			Next:  next,
			Itgen: itergen,
		}
		mc.keys = append(mc.keys, ts)
	} else {
		mc.chunks[ts].Prev = prev
	}

	if sortKeys {
		sort.Sort(accnt.Uint32Asc(mc.keys))
	}
}
173674
func (s *S3Resource) SetKeyRange(v *KeyRange) *S3Resource {
	s.KeyRange = v
	return s
}
23790
func (server *UpdateStream) StreamKeyRange(req *binlogdatapb.StreamKeyRangeRequest, stream binlogservicepb.UpdateStream_StreamKeyRangeServer) (err error) {
	defer server.updateStream.HandlePanic(&err)
	return server.updateStream.StreamKeyRange(stream.Context(), req.Position, req.KeyRange, req.Charset, func(reply *binlogdatapb.BinlogTransaction) error {
		return stream.Send(&binlogdatapb.StreamKeyRangeResponse{
			BinlogTransaction: reply,
		})
	})
}
697377
func (tr Ranges) AddRange(r Range) Ranges {
	res := tr.clone()
	res.addRangeInPlace(r)
	return res
}
39851
func (bk *Bucket) MapRange(do func(k, v []byte) error, min, max []byte) error {
	return bk.db.View(func(tx *bolt.Tx) error {
		c := tx.Bucket(bk.Name).Cursor()
		for k, v := c.Seek(min); isBefore(k, max); k, v = c.Next() {
			do(k, v)
		}
		return nil
	})
}
1362396
func (db *DB) LRange(key []byte, start int32, stop int32) ([][]byte, error) {
	if err := checkKeySize(key); err != nil {
		return nil, err
	}

	var headSeq int32
	var llen int32
	var err error

	metaKey := db.lEncodeMetaKey(key)

	it := db.bucket.NewIterator()
	defer it.Close()

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

	if start < 0 {
		start = llen + start
	}
	if stop < 0 {
		stop = llen + stop
	}
	if start < 0 {
		start = 0
	}

	if start > stop || start >= llen {
		return [][]byte{}, nil
	}

	if stop >= llen {
		stop = llen - 1
	}

	limit := (stop - start) + 1
	headSeq += start

	v := make([][]byte, 0, limit)

	startKey := db.lEncodeListKey(key, headSeq)
	rit := store.NewRangeLimitIterator(it,
		&store.Range{
			Min:  startKey,
			Max:  nil,
			Type: store.RangeClose},
		&store.Limit{
			Offset: 0,
			Count:  int(limit)})

	for ; rit.Valid(); rit.Next() {
		v = append(v, rit.Value())
	}

	return v, nil
}
75629
func (t *TSMReader) TombstoneRange(key []byte, buf []TimeRange) []TimeRange {
	t.mu.RLock()
	tr := t.index.TombstoneRange(key, buf)
	t.mu.RUnlock()
	return tr
}
661967
func (c *asyncClient) Lrange(arg0 string, arg1 int64, arg2 int64) (result FutureBytesArray, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(strconv.FormatInt(arg1, 10))
	arg2bytes := []byte(strconv.FormatInt(arg2, 10))

	var resp *PendingResponse
	resp, err = c.conn.QueueRequest(&LRANGE, [][]byte{arg0bytes, arg1bytes, arg2bytes})
	if err == nil {
		result = resp.future.(FutureBytesArray)
	}
	return result, err

}
746072
func (s *ParseStack) MarkComplete(ast AST) {
	s.list[s.index] = ast
	s.index++
}
1265290
func IPRange(start, stop net.IP) int {
	return int(binary.BigEndian.Uint32(stop.To4())) - int(binary.BigEndian.Uint32(start.To4())) + 1
}