// Range accepts an even number of arguments. Each pair of values defines start and end of range.
// Think like this: Range(from, to [, from, to ...])
331935
func (v *VerbalExpression) Range(args ...interface{}) *VerbalExpression {
	if len(args)%2 != 0 {
		log.Panicf("Range: not even args number")
	}

	parts := make([]string, 3)
	app := ""
	for i := 0; i < len(args); i++ {
		app += tostring(args[i])
		if i%2 != 0 {
			parts = append(parts, quote(app))
			app = ""
		} else {
			app += "-"
		}
	}
	return v.add("[" + strings.Join(parts, "") + "]")
}
91693
func (r *RangeOp) String() string {
	result := &bytes.Buffer{}
	if r.conditions == nil || len(r.conditions) == 0 {
		result.WriteString("<empty>")
	} else {
		// sort the fields by name for deterministic results
		keys := make([]string, 0, len(r.conditions))
		for key := range r.conditions {
			keys = append(keys, key)
		}
		sort.Strings(keys)
		for _, field := range keys {
			conds := r.conditions[field]
			if result.Len() > 0 {
				result.WriteString(", ")
			}
			result.WriteString(field)
			result.WriteString(" ")
			for i, cond := range conds {
				if i > 0 {
					_, _ = fmt.Fprintf(result, ", %s ", field)
				}
				_, _ = fmt.Fprintf(result, "%s %v", cond.Op.String(), cond.Value)
			}
		}
	}
	addLimitTokenString(result, r.limit, r.token)
	return result.String()
}
250891
func (c *Connector) Range(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error) {
	if limit == dosa.AdaptiveRangeLimit {
		limit = defaultRangeLimit
	}
	vals := make([]map[string]dosa.FieldValue, limit)
	for inx := range vals {
		vals[inx] = Data(ei, minimumFields)
	}
	return vals, randomString(32), nil
}
575979
func (f *fragment) rangeOp(op pql.Token, bitDepth uint, predicate uint64) (*Row, error) {
	switch op {
	case pql.EQ:
		return f.rangeEQ(bitDepth, predicate)
	case pql.NEQ:
		return f.rangeNEQ(bitDepth, predicate)
	case pql.LT, pql.LTE:
		return f.rangeLT(bitDepth, predicate, op == pql.LTE)
	case pql.GT, pql.GTE:
		return f.rangeGT(bitDepth, predicate, op == pql.GTE)
	default:
		return nil, ErrInvalidRangeOperation
	}
}
14799
func FullRange() []*Range {
	return []*Range{{LowVal: []types.Datum{{}}, HighVal: []types.Datum{types.MaxValueDatum()}}}
}
500901
func allRanges(b, pattern []byte) (ranges []matchRange) {
	i := 0
	for {
		sub := b[i:len(b)]
		idx := bytes.Index(sub, pattern)
		if idx == -1 {
			return
		}

		ranges = append(ranges, matchRange{first: idx + i, last: idx + i + len(pattern)})

		i += idx + 1
		if i > len(b)-1 {
			return
		}
	}
}
787584
func (r Range) String() string {
	return fmt.Sprintf("(%d, %d)", r.Start, r.Stop)
}
1066255
func (tr Ranges) AddRanges(other Ranges) Ranges {
	res := tr.clone()
	it := other.Iter()
	for it.Next() {
		res.addRangeInPlace(it.Value())
	}
	return res
}
476034
func (dt *doneTODOs) Range() (reflect.Value, reflect.Value, bool) {
	for dt.i < dt.len {
		key := dt.keys[dt.i]
		dt.i++
		if dt.list[key].Done {
			return reflect.ValueOf(key), reflect.ValueOf(dt.list[key]), false
		}
	}
	return reflect.Value{}, reflect.Value{}, true
}
1362766
func RangeArgs(min int, max int) PositionalArgs {
	return func(cmd *Command, args []string) error {
		if len(args) < min || len(args) > max {
			return fmt.Errorf("accepts between %d and %d arg(s), received %d", min, max, len(args))
		}
		return nil
	}
}
459919
func splitRange(start, stop, n int, fn func(pstart, pstop int)) {
	count := stop - start
	if count < 1 {
		return
	}

	if n < 1 {
		n = 1
	}
	if n > count {
		n = count
	}

	div := count / n
	mod := count % n

	for i := 0; i < n; i++ {
		fn(
			start+i*div+minint(i, mod),
			start+(i+1)*div+minint(i+1, mod),
		)
	}
}
954476
func (r Range) Before(other Range) bool {
	return !r.End.After(other.Start)
}
748317
func Range(start, end float64) []float64 {
	return Seq{NewLinear().WithStart(start).WithEnd(end).WithStep(1.0)}.Array()
}
828359
func (v Value) InRange(a, b Value) bool {
	return v-a < b-a
}
1075632
func (tr Ranges) String() string {
	var buf bytes.Buffer
	buf.WriteString("[")
	if tr.sortedRanges != nil {
		for e := tr.sortedRanges.Front(); e != nil; e = e.Next() {
			buf.WriteString(e.Value.(Range).String())
			if e.Next() != nil {
				buf.WriteString(",")
			}
		}
	}
	buf.WriteString("]")
	return buf.String()
}
697377
func (tr Ranges) AddRange(r Range) Ranges {
	res := tr.clone()
	res.addRangeInPlace(r)
	return res
}
88816
func (b *Bitmap) OffsetRange(offset, start, end uint64) *Bitmap {
	if lowbits(offset) != 0 {
		panic("offset must not contain low bits")
	}
	if lowbits(start) != 0 {
		panic("range start must not contain low bits")
	}
	if lowbits(end) != 0 {
		panic("range end must not contain low bits")
	}

	off := highbits(offset)
	hi0, hi1 := highbits(start), highbits(end)
	citer, _ := b.Containers.Iterator(hi0)
	other := NewBitmap()
	for citer.Next() {
		k, c := citer.Value()
		if k >= hi1 {
			break
		}
		other.Containers.Put(off+(k-hi0), c)
	}
	return other
}