// checkLengths reports whether the codes form a complete prefix tree.
966528
func (pc PrefixCodes) checkLengths() bool {
	sum := 1 << valueBits
	for _, c := range pc {
		sum -= (1 << valueBits) >> uint(c.Len)
	}
	return sum == 0 || len(pc) == 0
}
565237
func Check(ex pkix.Extension, d *certdata.Data) *errors.Errors {
	var e = errors.New(nil)

	// If the cert type isn't one of the `allowedCertTypes`, return an error
	if _, allowed := allowedCertTypes[d.Type]; !allowed {
		e.Err(certTypeErr)
	}

	// Per RFC 7633 "The TLS feature extension SHOULD NOT be marked critical"
	if ex.Critical {
		e.Err(critExtErr)
	}

	// Check that the extension value is the expected slice of DER encoded ASN.1
	if bytes.Compare(ex.Value, expectedExtensionValue) != 0 {
		e.Err(extValueErr)
	}

	return e
}
668174
func (q *MoreLikeThisQuery) MinWordLength(minWordLength int) *MoreLikeThisQuery {
	q.minWordLength = &minWordLength
	return q
}
238584
func intLength(bits, base int) int {
	return int(math.Ceil(float64(bits) * math.Log10(2.0) / math.Log10(float64(base))))
}
811065
func (s *StringCodeGenerator) ToolLengthChange(h int) {
	switch h {
	case 0:
		s.put("G49")
	default:
		s.put(fmt.Sprintf("G43H%d", h))
	}
}
243494
func (v *EntryBuffer) GetLength() uint {
	panic_if_version_older_auto(2, 18, 0)
	return uint(C._gtk_entry_buffer_get_length(v.GEntryBuffer))
}
681351
func (st *Store) MaxLength(l int) {
	for _, c := range st.Codecs {
		if codec, ok := c.(*securecookie.SecureCookie); ok {
			codec.MaxLength(l)
		}
	}
}
571356
func hasPathPrefix(s, pathPrefix string) bool {

	s = strings.TrimSuffix(s, "/")
	pathPrefix = strings.TrimSuffix(pathPrefix, "/")

	// Short circuit if s doesn't contain the prefix at all
	if !strings.HasPrefix(s, pathPrefix) {
		return false
	}

	pathPrefixLength := len(pathPrefix)

	if len(s) == pathPrefixLength {
		// Exact match
		return true
	}

	if s[pathPrefixLength:pathPrefixLength+1] == "/" {
		// The next character in s is a path segment boundary
		// Check this instead of normalizing pathPrefix to avoid allocating on every call
		// Example where this check applies: s=/foo/bar and pathPrefix=/foo
		return true
	}

	return false
}
643805
func MaxLength(length int) Validator {
	// return a validator that checks the length of the string
	return func(val interface{}) error {
		if str, ok := val.(string); ok {
			// if the string is longer than the given value
			if len([]rune(str)) > length {
				// yell loudly
				return fmt.Errorf("value is too long. Max length is %v", length)
			}
		} else {
			// otherwise we cannot convert the value into a string and cannot enforce length
			return fmt.Errorf("cannot enforce length on response of type %v", reflect.TypeOf(val).Name())
		}

		// the input is fine
		return nil
	}
}
563362
func (q *TermQuery) PrefixLength(length int) *TermQuery {
	q.options["prefix_length"] = length
	return q
}
384362
func (s *Scanner) readLength(first byte) (int64, error) {
	length := int64(first & maskFirstLength)

	c := first
	shift := firstLengthBits
	var err error
	for c&maskContinue > 0 {
		if c, err = s.r.ReadByte(); err != nil {
			return 0, err
		}

		length += int64(c&maskLength) << shift
		shift += lengthBits
	}

	return length, nil
}
371647
func (o *ElapseParams) validateLength(formats strfmt.Registry) error {

	if err := validate.MinimumInt("length", "path", int64(o.Length), 2, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("length", "path", int64(o.Length), 30, false); err != nil {
		return err
	}

	return nil
}
542046
func (v *Validator) MaxLength(field string, length int) *ValidationResult {
	val := v.data.Get(field)
	trimmed := strings.TrimSpace(val)
	if len(trimmed) > length {
		return v.addMaxLengthError(field, length)
	} else {
		return validationOk
	}
}
512098
func (sc *StringConstraint) MaxLength(l int) *StringConstraint {
	sc.maxLength = l
	return sc
}
609519
func checkStrings(L *lua.LState, n int) []string {
	params := L.GetTop()
	if n > params {
		return []string{}
	}
	args := make([]string, 0, (params - n + 1))
	for i := n; i <= params; i++ {
		p := L.Get(i)
		if p.Type() == lua.LTUserData {
			continue
		}
		L.CheckTypes(i, lua.LTString, lua.LTNumber)
		args = append(args, p.String())
	}
	return args
}
939024
func (f *FileAsset) GetLength() int {
	file, err := os.Open(f.AssetName)
	defer file.Close()
	if err != nil {
		return 0
	}
	fi, err := file.Stat()
	if err != nil {
		return 0
	}
	return int(fi.Size())
}
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)
}