// Clamp returns the value if it fits within the parameters min and max.
// Otherwise returns the closest boundary parameter value.
421116
func Clamp(value, min, max float64) float64 {
	if value > max {
		return max
	}
	if value < min {
		return min
	}
	return value
}
427309
func (bb BBox) Bound() orb.Bound {
	if !bb.Valid() {
		return orb.Bound{}
	}

	mid := len(bb) / 2

	return orb.Bound{
		Min: orb.Point{bb[0], bb[1]},
		Max: orb.Point{bb[mid], bb[mid+1]},
	}
}
1096235
def clamp(value, lower=0, upper=sys.maxsize):
    """"""
    return max(lower, min(upper, value))
443525
func Min(v T) interface{} {
	x, _ := minmax(v, -1, true)
	return x.Interface()
}
187712
func clamp(x float64) uint8 {
	v := int64(x + 0.5)
	if v > 255 {
		return 255
	}
	if v > 0 {
		return uint8(v)
	}
	return 0
}
814224
function clamp(pos) {
        pos.top = Math.max(Math.min(pos.top, bounds.bottom - containerNode.offsetHeight), bounds.top);
        pos.left = Math.max(Math.min(pos.left, bounds.right - containerNode.offsetWidth), bounds.left);
      }
1102955
func (ins Inputs) SoftClip() Input {
	clipped := make([]Input, len(ins))
	for i, in := range ins {
		clipped[i] = in.SoftClip()
	}
	return Inputs(clipped)
}
1355824
func CheckBoundedArgs(argBounds Bounds, args []string) error {
	if argBounds.Min == 0 && argBounds.Max == 0 {
		if len(args) != 0 {
			return fmt.Errorf("Expected no args, got %d", len(args))
		}
		return nil
	}
	if argBounds.Max == 0 {
		if len(args) < argBounds.Min {
			return fmt.Errorf("Expected at least %d args, got %d", argBounds.Min, len(args))
		}
		return nil
	}
	if argBounds.Min == 0 {
		if len(args) > argBounds.Max {
			return fmt.Errorf("Expected at most %d args, got %d", argBounds.Max, len(args))
		}
		return nil
	}
	if len(args) < argBounds.Min || len(args) > argBounds.Max {
		if argBounds.Min == argBounds.Max {
			return fmt.Errorf("Expected %d args, got %d", argBounds.Min, len(args))
		}
		return fmt.Errorf("Expected between %d and %d args, got %d", argBounds.Min, argBounds.Max, len(args))
	}
	return nil
}
532775
func Bound(bound orb.Bound, proj orb.Projection) orb.Bound {
	min := proj(bound.Min)
	return orb.Bound{Min: min, Max: min}.Extend(proj(bound.Max))
}
1328641
func (db *DB) compTriggerRange(compC chan<- cCmd, level int, min, max []byte) (err error) {
	ch := make(chan error)
	defer close(ch)
	// Send cmd.
	select {
	case compC <- cRange{level, min, max, ch}:
	case err := <-db.compErrC:
		return err
	case <-db.closeC:
		return ErrClosed
	}
	// Wait cmd.
	select {
	case err = <-ch:
	case err = <-db.compErrC:
	case <-db.closeC:
		return ErrClosed
	}
	return err
}
628409
func (mls MultiLineString) Bound() Bound {
	if len(mls) == 0 {
		return emptyBound
	}

	bound := mls[0].Bound()
	for i := 1; i < len(mls); i++ {
		bound = bound.Union(mls[i].Bound())
	}

	return bound
}
1263073
func (ic *IntegerConstraint) Maximum(n float64) *IntegerConstraint {
	ic.applyMaximum = true
	ic.maximum = n
	return ic
}
277326
public static int clamp(int value, int min, int max) {
		return Math.min(Math.max(min, value), max);
	}
293894
func (vec *T) Clamped(min, max *T) T {
	result := *vec
	result.Clamp(min, max)
	return result
}
951667
func (c Color) Clamped() Color {
	return Color{clamp01(c.R), clamp01(c.G), clamp01(c.B)}
}
566713
func (mp MultiPolygon) Bound() Bound {
	if len(mp) == 0 {
		return emptyBound
	}
	bound := mp[0].Bound()
	for i := 1; i < len(mp); i++ {
		bound = bound.Union(mp[i].Bound())
	}

	return bound
}
1083515
func (i Interval) ClampPoint(p float64) float64 {
	return math.Max(i.Lo, math.Min(i.Hi, p))
}