// If the data is longer than max, return a subset of length max.
176613
func (data ChartUints) snip(max int) ChartUints {
	if len(data) < max {
		max = len(data)
	}
	return data[:max]
}
227245
func (fs *FileSet) MaxID() int {
	var max int
	for _, f := range fs.files {
		if i := f.ID(); i > max {
			max = i
		}
	}
	return max
}
234751
func getlength(bs *BlockDriverState) (int64, error) {
	length, err := nbSectors(bs)
	if err != nil {
		return 0, err
	}

	if length > int64(INT64_MAX/BDRV_SECTOR_SIZE) {
		return 0, syscall.EFBIG
	}
	return length * int64(BDRV_SECTOR_SIZE), 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
}
574064
func MaxLength(path, in, data string, maxLength int64) *errors.Validation {
	strLen := int64(utf8.RuneCount([]byte(data)))
	if strLen > maxLength {
		return errors.TooLong(path, in, maxLength)
	}
	return nil
}
1065779
func getMiddle(lowStr, highStr string) *big.Int {
	low := bigIntFromStr(lowStr, 10)
	high := bigIntFromStr(highStr, 10)
	if low.Cmp(high) != -1 {
		die(false, "Error: %s is not smaller than %s", lowStr, highStr)
	}
	middle := new(big.Int)
	middle = middle.Div(middle.Add(low, high), big.NewInt(2))
	return middle
}
48282
func (macds *MACDSignalSeries) Len() int {
	if macds.InnerSeries == nil {
		return 0
	}

	return macds.InnerSeries.Len()
}
1237242
func MinLength(path, in, data string, minLength int64) *errors.Validation {
	strLen := int64(utf8.RuneCount([]byte(data)))
	if strLen < minLength {
		return errors.TooShort(path, in, minLength)
	}
	return nil
}
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
}
512098
func (sc *StringConstraint) MaxLength(l int) *StringConstraint {
	sc.maxLength = l
	return sc
}
1274368
func getMaxMinFromDimensionRef(ref string) (minx, miny, maxx, maxy int, err error) {
	var parts []string
	parts = strings.Split(ref, cellRangeChar)
	minx, miny, err = GetCoordsFromCellIDString(parts[0])
	if err != nil {
		return -1, -1, -1, -1, err
	}
	maxx, maxy, err = GetCoordsFromCellIDString(parts[1])
	if err != nil {
		return -1, -1, -1, -1, err
	}
	return
}
1181390
func (fs *TermvectorsFilterSettings) MaxWordLength(value int64) *TermvectorsFilterSettings {
	fs.maxWordLength = &value
	return fs
}
771645
func (s SeqSet) search(q uint32) (i int, ok bool) {
	min, max := 0, len(s.Set)-1
	for min < max {
		if mid := (min + max) >> 1; s.Set[mid].Less(q) {
			min = mid + 1
		} else {
			max = mid
		}
	}
	if max < 0 || s.Set[min].Less(q) {
		return len(s.Set), false // q is the new largest value
	}
	return min, s.Set[min].Contains(q)
}
453404
func (prs PolynomialRegressionSeries) Len() int {
	return util.Math.MinInt(prs.GetLimit(), prs.InnerSeries.Len()-prs.GetOffset())
}
22170
func Maximum() (int, error) {
	var limit syscall.Rlimit
	if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
		return 0, err
	}
	return int(limit.Max), nil
}
245790
func (p Pages) ByLength() Pages {

	const key = "pageSort.ByLength"

	length := func(p1, p2 Page) bool {

		p1l, ok1 := p1.(resource.LengthProvider)
		p2l, ok2 := p2.(resource.LengthProvider)

		if !ok1 {
			return true
		}

		if !ok2 {
			return false
		}

		return p1l.Len() < p2l.Len()
	}

	pages, _ := spc.get(key, pageBy(length).Sort, p)

	return pages
}
901720
func (s Slice) GetStringLength() (ValueLength, error) {
	h := s.head()
	if h >= 0x40 && h <= 0xbe {
		// short UTF-8 String
		length := h - 0x40
		return ValueLength(length), nil
	}

	if h == 0xbf {
		// long UTF-8 String
		length := readIntegerFixed(s[1:], 8)
		if err := checkOverflow(ValueLength(length)); err != nil {
			return 0, WithStack(err)
		}
		return ValueLength(length), nil
	}

	return 0, InvalidTypeError{"Expecting type String"}
}