//gets the length of string, map or array
502166
func ToLength(input interface{}) (int, bool) {
	if s, ok := input.(string); ok {
		return len(s), true
	}

	value := reflect.ValueOf(input)
	kind := value.Kind()
	if kind == reflect.Array || kind == reflect.Slice || kind == reflect.Map {
		return value.Len(), true
	}
	return 0, false
}
782499
func ToLength(i, rpl string, length int) string {
	if len(i) == length {
		return i
	} else if len(i) > length {
		return i[:length]
	} else {
		for idx := 0; idx <= length-len(i); idx++ {
			i += rpl
		}
		return i
	}
}
845385
func length(v interface{}, param string) error {
	st := reflect.ValueOf(v)
	valid := true
	if st.Kind() == reflect.Ptr {
		if st.IsNil() {
			return nil
		}
		st = st.Elem()
	}
	switch st.Kind() {
	case reflect.String:
		p, err := asInt(param)
		if err != nil {
			return ErrBadParameter
		}
		valid = int64(len(st.String())) == p
	case reflect.Slice, reflect.Map, reflect.Array:
		p, err := asInt(param)
		if err != nil {
			return ErrBadParameter
		}
		valid = int64(st.Len()) == p
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		p, err := asInt(param)
		if err != nil {
			return ErrBadParameter
		}
		valid = st.Int() == p
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		p, err := asUint(param)
		if err != nil {
			return ErrBadParameter
		}
		valid = st.Uint() == p
	case reflect.Float32, reflect.Float64:
		p, err := asFloat(param)
		if err != nil {
			return ErrBadParameter
		}
		valid = st.Float() == p
	default:
		return ErrUnsupported
	}
	if !valid {
		return ErrLen
	}
	return nil
}
1143443
func (s *RedisDownlinkQueue) Length() (int, error) {
	return s.queues.Length(s.key())
}
302218
func StringMap(result interface{}, err error) (map[string]string, error) {
    values, err := Values(result, err)
    if err != nil {
	return nil, err
    }
    if len(values) % 2 != 0 {
	return nil, errors.New("expect even number elements for StringMap")
    }

    m := make(map[string]string, len(values) / 2)
    for i := 0; i < len(values); i += 2 {
	key, okKey := values[i].([]byte)
	value, okValue := values[i + 1].([]byte)
	if !okKey || !okValue {
	    return nil, errors.New("expect bulk string for StringMap")
	}
	m[string(key)] = string(value)
    }

    return m, nil
}
1277860
func (p *Partial) SliceOfLength(length int) (a []*Partial, err error) {
	err = p.Unmarshal(&a)
	if err != nil {
		return
	}

	if len(a) != length {
		err = errors.New("Invalid array length")
	}

	return
}
1025918
func ExtractLength(opts ...interface{}) *opt.LengthOption {
	for _, o := range opts {
		if v, ok := o.(*opt.LengthOption); ok {
			return v
		}
	}
	return nil
}
127537
func String(length, cardinality int) string {
	globalLk.Lock()
	defer globalLk.Unlock()
	return globalGen.String(length, cardinality)
}
891924
func (m *Map) GetMaxPrefixLengths(ipv6 bool) (count int) {
	if IPCache.MapType == bpf.BPF_MAP_TYPE_LPM_TRIE {
		if ipv6 {
			return net.IPv6len*8 + 1
		} else {
			return net.IPv4len*8 + 1
		}
	}
	if ipv6 {
		return maxPrefixLengths6
	}
	return maxPrefixLengths4
}
720600
func readHexLength(r io.Reader) (int, error) {
	lengthHex := make([]byte, 4)
	n, err := io.ReadFull(r, lengthHex)
	if err != nil {
		return 0, errIncompleteMessage("length", n, 4)
	}

	length, err := strconv.ParseInt(string(lengthHex), 16, 64)
	if err != nil {
		return 0, errors.WrapErrorf(err, errors.NetworkError, "could not parse hex length %v", lengthHex)
	}

	// Clip the length to 255, as per the Google implementation.
	if length > MaxMessageLength {
		length = MaxMessageLength
	}

	return int(length), nil
}
1090891
func (a *Array) Length() *Number {
	return &Number{a.chain, float64(len(a.value))}
}
259533
func (lru *LRUCache) Length() int64 {
	lru.mu.Lock()
	defer lru.mu.Unlock()
	return int64(lru.list.Len())
}
74988
func (arguments Arguments) LengthNonIndexed() int {
	out := 0
	for _, arg := range arguments {
		if !arg.Indexed {
			out++
		}
	}
	return out
}
1209447
func (g *LineString) Length() float64 {
	return length1(g.flatCoords, 0, len(g.flatCoords), g.stride)
}
613279
func (l *Language) GetStringMapString(key string) map[string]string {
	return cast.ToStringMapString(l.Get(key))
}
659134
func Width(str string) int {
	var r rune
	var size, n int

	for len(str) > 0 {
		r, size = utf8.DecodeRuneInString(str)
		n += RuneWidth(r)
		str = str[size:]
	}

	return n
}
478984
func (s *String) Length() *Number {
	return &Number{s.chain, float64(len(s.value))}
}