12345678910111213141516171819202122232425262728 |
- /*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- */
- package netaddr
- func min(a, b int) int {
- if a < b {
- return a
- }
- return b
- }
- func max(a, b int) int {
- if a < b {
- return b
- }
- return a
- }
- func clamp(x, a, b int) int {
- if a > b {
- a, b = b, a
- }
- return min(max(x, a), b)
- }
|