// Max returns the maximum value seen in the last 10 seconds.
554893
func (r *Number) Max(now time.Time) float64 {
	var max float64

	r.Mutex.RLock()
	defer r.Mutex.RUnlock()

	for timestamp, bucket := range r.Buckets {
		// TODO: configurable rolling window
		if timestamp >= now.Unix()-10 {
			if bucket.Value > max {
				max = bucket.Value
			}
		}
	}

	return max
}
494525
func MaxTime(a, b time.Time) time.Time {
	if a.After(b) {
		return a
	}
	return b
}
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
}
440023
func maxOf(a, b time.Duration) time.Duration {
	// lol no ternary statements
	if a > b {
		return a
	}

	return b
}
4312
func (s *FieldStats) SetMax(v string) *FieldStats {
	s.Max = &v
	return s
}
575290
func (c *Call) MaxTimes(n int) *Call {
	c.maxCalls = n
	if c.minCalls == 1 {
		c.minCalls = 0
	}
	return c
}
645395
func (c *Container) max() uint16 {
	if c.isArray() {
		return c.arrayMax()
	} else if c.isRun() {
		return c.runMax()
	} else {
		return c.bitmapMax()
	}
}
808331
func (c *Cookie) MaxAge(p int) *Cookie {
	c.cookie.MaxAge = p
	return c
}
489325
func (nc *NumberConstraint) Maximum(n float64) *NumberConstraint {
	nc.applyMaximum = true
	nc.maximum = n
	return nc
}
236492
func max(n []int) int {
	val := 0
	for _, i := range n {
		if i > val {
			val = i
		}
	}
	return val
}
480892
func MinMax(min, max time.Time) (time.Time, time.Time) {
	if IsGreaterThan(min, max, false) {
		return max, min
	}
	return min, max
}
600851
func (s Seq) Max() float64 {
	if s.Len() == 0 {
		return 0
	}
	max := s.GetValue(0)
	var value float64
	for i := 1; i < s.Len(); i++ {
		value = s.GetValue(i)
		if value > max {
			max = value
		}
	}
	return max
}
748692
func Max(a, b []float32) {
	b = b[:len(a)]

	for i, v := range a {
		bv := b[i]
		if bv > v {
			a[i] = bv
		}
	}
}
328512
func (v *view) max(filter *Row, bitDepth uint) (max, count uint64, err error) {
	for _, f := range v.allFragments() {
		fmax, fcount, err := f.max(filter, bitDepth)
		if err != nil {
			return max, count, err
		}
		if fcount > 0 && fmax > max {
			max = fmax
			count += fcount
		}
	}
	return max, count, nil
}
1311107
func MaxTime(t1, t2 time.Time) time.Time {
	if t1.After(t2) {
		return t1
	}
	return t2
}
401317
func (t TimeRange) MaxTime() time.Time {
	if t.Max.IsZero() {
		return maxTime
	}
	return t.Max
}
1038705
func Minmax(data Interface) (min float64, min_index int, max float64, max_index int) {
	Len := data.Len()
	min = data.Get(0)
	max = data.Get(0)

	for i := 0; i < Len; i++ {
		xi := data.Get(i)

		if xi < min {
			min = xi
			min_index = i
		}

		if xi > max {
			max = xi
			max_index = i
		}

		if math.IsNaN(xi) {
			min = xi
			max = xi
			min_index = i
			max_index = i
			break
		}
	}

	return
}