/*Trange - True Range

Input = High, Low, Close

Output = double

*/
429573
func Trange(high, low, close []float64) []float64 {
	var outBegIdx C.int
	var outNBElement C.int
	outReal := make([]float64, len(high))
	C.TA_TRANGE(0, C.int(len(high)-1), (*C.double)(unsafe.Pointer(&high[0])), (*C.double)(unsafe.Pointer(&low[0])), (*C.double)(unsafe.Pointer(&close[0])), &outBegIdx, &outNBElement, (*C.double)(unsafe.Pointer(&outReal[0])))
	return outReal[:outNBElement]
}
1350009
func (m *boxMap) Range(f func(key string, value *Box) bool) {
	m.data.Range(func(k, v interface{}) bool {
		key, ok := k.(string)
		if !ok {
			return false
		}
		value, ok := v.(*Box)
		if !ok {
			return false
		}
		return f(key, value)
	})
}
618199
func (s *Statement) Range() *Statement {
	// notest
	t := token{
		content: "range",
		typ:     keywordToken,
	}
	*s = append(*s, t)
	return s
}
92047
func fmtF(dst []byte, neg bool, d decimalSlice, prec int) []byte {
	// sign
	if neg {
		dst = append(dst, '-')
	}

	// integer, padded with zeros as needed.
	if d.dp > 0 {
		var i int
		for i = 0; i < d.dp && i < d.nd; i++ {
			dst = append(dst, d.d[i])
		}
		for ; i < d.dp; i++ {
			dst = append(dst, '0')
		}
	} else {
		dst = append(dst, '0')
	}

	// fraction
	if prec > 0 {
		dst = append(dst, '.')
		for i := 0; i < prec; i++ {
			ch := byte('0')
			if j := d.dp + i; 0 <= j && j < d.nd {
				ch = d.d[j]
			}
			dst = append(dst, ch)
		}
	}

	return dst
}
355892
func (s Slice) CompareString(value string) (int, error) {
	k, err := s.GetStringUTF8()
	if err != nil {
		return 0, WithStack(err)
	}
	return bytes.Compare(k, []byte(value)), nil
}
813218
func parseLexrange(s string) (string, bool, error) {
	if len(s) == 0 {
		return "", false, errInvalidRangeItem
	}
	if s == "+" || s == "-" {
		return s, false, nil
	}
	switch s[0] {
	case '(':
		return s[1:], false, nil
	case '[':
		return s[1:], true, nil
	default:
		return "", false, errInvalidRangeItem
	}
}
381742
func outof(args ...interface{}) (interface{}, error) {
	toret := "outof("
	if len(args) < 2 {
		return nil, fmt.Errorf("Expected at least two arguments to NOutOf. Given %d", len(args))
	}

	arg0 := args[0]
	// govaluate treats all numbers as float64 only. But and/or may pass int/string. Allowing int/string for flexibility of caller
	if n, ok := arg0.(float64); ok {
		toret += strconv.Itoa(int(n))
	} else if n, ok := arg0.(int); ok {
		toret += strconv.Itoa(n)
	} else if n, ok := arg0.(string); ok {
		toret += n
	} else {
		return nil, fmt.Errorf("Unexpected type %s", reflect.TypeOf(arg0))
	}

	for _, arg := range args[1:] {
		toret += ", "
		switch t := arg.(type) {
		case string:
			if regex.MatchString(t) {
				toret += "'" + t + "'"
			} else {
				toret += t
			}
		default:
			return nil, fmt.Errorf("Unexpected type %s", reflect.TypeOf(arg))
		}
	}
	return toret + ")", nil
}
400384
func (t *Transition) To(to uint8) *Transition {
	t.to = to
	t.toSet = true
	t.recalculate()
	return t
}
1269168
func SliceToLower(s []string) []string {
	if s == nil {
		return nil
	}

	l := make([]string, len(s))
	for i, v := range s {
		l[i] = strings.ToLower(v)
	}

	return l
}
588789
func (q *TransmitLimitedQueue) getTransmitRange() (minTransmit, maxTransmit int) {
	if q.lenLocked() == 0 {
		return 0, 0
	}
	minItem, maxItem := q.tq.Min(), q.tq.Max()
	if minItem == nil || maxItem == nil {
		return 0, 0
	}

	min := minItem.(*limitedBroadcast).transmits
	max := maxItem.(*limitedBroadcast).transmits

	return min, max
}
475317
func Convert(input []byte, output []byte, fromEncoding string, toEncoding string) (bytesRead int, bytesWritten int, err error) {
	// create a temporary converter
	converter, err := NewConverter(fromEncoding, toEncoding)

	if err == nil {
		// call converter's Convert
		bytesRead, bytesWritten, err = converter.Convert(input, output)

		if err == nil {
			var shiftBytesWritten int

			// call Convert with a nil input to generate any end shift sequences
			_, shiftBytesWritten, err = converter.Convert(nil, output[bytesWritten:])

			// add shift bytes to total bytes
			bytesWritten += shiftBytesWritten
		}

		// close the converter
		converter.Close()
	}

	return
}
83184
func (d *MyDecimal) Compare(to *MyDecimal) int {
	if d.negative == to.negative {
		cmp, err := doSub(d, to, nil)
		terror.Log(errors.Trace(err))
		return cmp
	}
	if d.negative {
		return -1
	}
	return 1
}
995244
func (ifft IFFT) Rate(rate int8) Input {
	CheckRate(rate)
	(&ifft).defaults()
	return NewInput("IFFT", rate, 0, 1, ifft.Buffer, ifft.WinType, ifft.WinSize)
}
844418
func (this *Converter) ConvertString(input string) (output string, err error) {
	// make sure we are still open
	if this.open {
		// construct the buffers
		inputBuffer := []byte(input)
		outputBuffer := make([]byte, len(inputBuffer)*2) // we use a larger buffer to help avoid resizing later

		// call Convert until all input bytes are read or an error occurs
		var bytesRead, totalBytesRead, bytesWritten, totalBytesWritten int

		for totalBytesRead < len(inputBuffer) && err == nil {
			// use the totals to create buffer slices
			bytesRead, bytesWritten, err = this.Convert(inputBuffer[totalBytesRead:], outputBuffer[totalBytesWritten:])

			totalBytesRead += bytesRead
			totalBytesWritten += bytesWritten

			// check for the E2BIG error specifically, we can add to the output
			// buffer to correct for it and then continue
			if err == syscall.E2BIG {
				// increase the size of the output buffer by another input length
				// first, create a new buffer
				tempBuffer := make([]byte, len(outputBuffer)+len(inputBuffer))

				// copy the existing data
				copy(tempBuffer, outputBuffer)

				// switch the buffers
				outputBuffer = tempBuffer

				// forget the error
				err = nil
			}
		}

		if err == nil {
			// perform a final shift state reset
			_, bytesWritten, err = this.Convert([]byte{}, outputBuffer[totalBytesWritten:])

			// update total count
			totalBytesWritten += bytesWritten
		}

		// construct the final output string
		output = string(outputBuffer[:totalBytesWritten])
	} else {
		err = syscall.EBADF
	}

	return output, err
}
727104
func gorocksdb_slicetransform_in_range(idx int, cKey *C.char, cKeyLen C.size_t) C.uchar {
	key := charToByte(cKey, cKeyLen)
	inRange := sliceTransforms.Get(idx).(sliceTransformWrapper).sliceTransform.InRange(key)
	return boolToChar(inRange)
}
1373292
func splitRange(value string) (string, string, error) {
	p := strings.SplitN(value, ",", 2)
	if len(p) != 2 || p[0] == "" || p[1] == "" {
		return "", "", fmt.Errorf("date: failed to parse date range '%s'", value)
	}
	return strings.ToLower(p[0][1:]), strings.ToLower(p[1][:len(p[1])-1]), nil
}
909934
func ValueToString(val Value) (string, bool) {
	if val == nil || val.Err() {
		return "", false
	}
	switch v := val.(type) {
	case StringValue:
		return v.Val(), true
	case TimeValue:
		return fmt.Sprintf("%v", v.Val()), true
	case ByteSliceValue:
		return string(v.Val()), true
	case NumericValue, BoolValue, IntValue:
		return val.ToString(), true
	case Slice:
		// This is controversial, if we are demanding a "ToString"
		// should we:
		// 1)  take first?
		// 2)  append comma separated?
		// 3)  error?
		//
		// Our answer is that we are demanding a scalar string
		// and going to take first.  calling function would have had to do type detection
		// if they wanted something else.
		if v.Len() == 0 {
			return "", false
		}
		v1 := v.SliceValue()[0]
		if v1 == nil {
			return "", false
		}
		return v1.ToString(), true
	}
	return "", false
}