// AlphaRange returns a random alphanumeric string at least min and no more
// than max characters long.
436077
func AlphaStringRange(min, max int) (string, error) {
	return StringRange(min, max, Alphanumeric)
}
962410
func UInt64Range(min, max uint64) gopter.Gen {
	if max < min {
		return Fail(reflect.TypeOf(uint64(0)))
	}
	d := max - min + 1
	if d == 0 { // Check overflow (i.e. max = MaxInt64, min = MinInt64)
		return func(genParams *gopter.GenParameters) *gopter.GenResult {
			return gopter.NewGenResult(genParams.NextUint64(), UInt64Shrinker)
		}
	}
	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		genResult := gopter.NewGenResult(min+genParams.NextUint64()%d, UInt64Shrinker)
		genResult.Sieve = func(v interface{}) bool {
			return v.(uint64) >= min && v.(uint64) <= max
		}
		return genResult
	}
}
946696
func (c *syncClient) Lrange(arg0 string, arg1 int64, arg2 int64) (result [][]byte, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(strconv.FormatInt(arg1, 10))
	arg2bytes := []byte(strconv.FormatInt(arg2, 10))

	var resp Response
	resp, err = c.conn.ServiceRequest(&LRANGE, [][]byte{arg0bytes, arg1bytes, arg2bytes})
	if err == nil {
		result = resp.GetMultiBulkData()
	}
	return result, err

}
1274507
func (ung UniformGenerator) ShuffleRange(arr []interface{}, low, high int) {
	if low < 0 || low > high || high >= len(arr) {
		panic(fmt.Sprintf("Illegal subarray range %d ~ %d", low, high))
	}
	for i := low; i <= high; i++ {
		r := int32(i) + ung.Int32n(int32(high-i+1))
		arr[i], arr[r] = arr[r], arr[i]
	}
}
1289610
func appendFoldedRange(r []rune, lo, hi rune) []rune {
	// Optimizations.
	if lo <= minFold && hi >= maxFold {
		// Range is full: folding can't add more.
		return appendRange(r, lo, hi)
	}
	if hi < minFold || lo > maxFold {
		// Range is outside folding possibilities.
		return appendRange(r, lo, hi)
	}
	if lo < minFold {
		// [lo, minFold-1] needs no folding.
		r = appendRange(r, lo, minFold-1)
		lo = minFold
	}
	if hi > maxFold {
		// [maxFold+1, hi] needs no folding.
		r = appendRange(r, maxFold+1, hi)
		hi = maxFold
	}

	// Brute force.  Depend on appendRange to coalesce ranges on the fly.
	for c := lo; c <= hi; c++ {
		r = appendRange(r, c, c)
		f := unicode.SimpleFold(c)
		for f != c {
			r = appendRange(r, f, f)
			f = unicode.SimpleFold(f)
		}
	}
	return r
}
316595
func (a *MinMaxAllocator) SetRange(min, max int) error {
	if min > max {
		return ErrInvalidRange
	}

	a.lock.Lock()
	defer a.lock.Unlock()

	// Check if we need to change
	if a.min == min && a.max == max {
		return nil
	}

	a.min = min
	a.max = max

	// Recompute how many free we have in the range
	numUsed := 0
	for i := range a.used {
		if a.inRange(i) {
			numUsed++
		}
	}
	a.free = 1 + max - min - numUsed

	return nil
}
828359
func (v Value) InRange(a, b Value) bool {
	return v-a < b-a
}
562634
func RandomString(n int) (string, error) {
	buffer := make([]byte, n)
	max := big.NewInt(int64(len(alphanum)))

	for i := 0; i < n; i++ {
		index, err := randomInt(max)
		if err != nil {
			return "", err
		}

		buffer[i] = alphanum[index]
	}

	return string(buffer), nil
}
270300
func (c *Client) GetRange(key string, start, end int) (string, error) {
	v, err := c.execWithKey(true, "GETRANGE", key, start, end)
	if err != nil {
		return "", err
	}
	switch v.(type) {
	case string:
		return v.(string), nil
	}
	return "", ErrServerError
}
1046689
func rangesAndLength(s string) (string, int, error) {
	expr := s[0:strings.LastIndex(s, "{")]
	if !expressionExp.MatchString(expr) {
		return "", 0, fmt.Errorf("malformed expresion syntax: %s", expr)
	}

	length, _ := strconv.Atoi(s[strings.LastIndex(s, "{")+1 : len(s)-1])
	// TODO: We do need to set a better limit for the number of generated characters.
	if length > 0 && length <= 255 {
		return expr, length, nil
	}
	return "", 0, fmt.Errorf("range must be within [1-255] characters (%d)", length)
}
1039145
func (s *SortCommand) Alpha(b bool) *SortCommand {
	s.alpha = b
	return s
}
1296019
func (d *downloader) downloadRange(rng string) {
	if d.getErr() != nil {
		return
	}

	chunk := dlchunk{w: d.w, start: d.pos}
	// Ranges specified will short circuit the multipart download
	chunk.withRange = rng

	if err := d.downloadChunk(chunk); err != nil {
		d.setErr(err)
	}

	// Update the position based on the amount of data received.
	d.pos = d.written
}
138781
func (c *dlchunk) ByteRange() string {
	if len(c.withRange) != 0 {
		return c.withRange
	}

	return fmt.Sprintf("bytes=%d-%d", c.start, c.start+c.size-1)
}
367686
func (r *attrRange) Subrange(start, end uint16) []attr {
	startidx := r.idx(int(start))
	switch startidx {
	case tooSmall:
		startidx = 0
	case tooLarge:
		return []attr{}
	}

	endidx := r.idx(int(end) + 1) // [start, end] includes its upper bound!
	switch endidx {
	case tooSmall:
		return []attr{}
	case tooLarge:
		endidx = len(r.aa)
	}
	return r.aa[startidx:endidx]
}
46867
func NewNumericRangeQuery(min, max *float64) *query.NumericRangeQuery {
	return query.NewNumericRangeQuery(min, max)
}
1340196
func Float64Range(min, max float64) gopter.Gen {
	d := max - min
	if d < 0 || d > math.MaxFloat64 {
		return Fail(reflect.TypeOf(float64(0)))
	}

	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		genResult := gopter.NewGenResult(min+genParams.Rng.Float64()*d, Float64Shrinker)
		genResult.Sieve = func(v interface{}) bool {
			return v.(float64) >= min && v.(float64) <= max
		}
		return genResult
	}
}
866575
func randIntRange(min, max int) int {
	if min == max {
		return min
	}
	return rand.Intn((max+1)-min) + min
}