// complement flips all bits in this array.
974250
func (ba *bitArray) complement() {
	for i := uint64(0); i < uint64(len(ba.blocks)); i++ {
		ba.blocks[i] = ^ba.blocks[i]
	}

	ba.setLowest()
	if ba.anyset {
		ba.setHighest()
	}
}
449413
func (i *Uint32) Swap(n uint32) uint32 {
	return atomic.SwapUint32(&i.v, n)
}
602750
func Mid(a, b, c int) int {
	if a >= b {
		if b >= c {
			return b
		} else if a >= c {
			return c
		} else {
			return a
		}
	} else {
		if c <= a {
			return a
		} else if c <= b {
			return c
		} else {
			return b
		}
	}
}
1124979
func (t list) Swap(a, b int) {
	t[a], t[b] = t[b], t[a]
}
87397
func (s *Bitset) Flip(index uint) *Bitset {
	if index >= s.Length(0) {
		s.Set(index)
	}
	s.set[unitPos(index)] ^= 1 << unitIndex(index)

	return s
}
1000461
func (i *Int64) Swap(n int64) int64 {
	return atomic.SwapInt64(&i.v, n)
}
510429
func (expr *Expr) Complement() *Expr {
	cpy := *expr
	cpy.Negated = !cpy.Negated
	return &cpy
}
560482
func (s ByteArraySlice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
994424
func (a AcceptSlice) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}
495042
func (s TimeSlice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
285713
func (vec *T) Invert() *T {
	vec[0] = -vec[0]
	vec[1] = -vec[1]
	vec[2] = -vec[2]
	return vec
}
623358
func ReverseSlice(slice interface{}) interface{} {
	switch reflect.TypeOf(slice).Kind() {
	case reflect.Slice, reflect.Ptr:
		values := reflect.Indirect(reflect.ValueOf(slice))
		if values.Len() == 0 {
			return slice
		}

		reversedSlice := reflect.MakeSlice(reflect.SliceOf(reflect.Indirect(values.Index(0)).Type()), values.Len(), values.Len())

		k := 0
		for i := values.Len() - 1; i >= 0; i-- {
			reversedSlice.Index(k).Set(copyElement(values.Index(i)))
			k++
		}

		return reversedSlice.Interface()
	default:
		panic(fmt.Sprintf("Type not allowed: %v", reflect.TypeOf(slice).Kind()))
	}
}
1109314
func reverse(u []byte) []byte {
	// Special-case 16 bit UUIDS for speed.
	l := len(u)
	if l == 2 {
		return []byte{u[1], u[0]}
	}
	b := make([]byte, l)
	for i := 0; i < l/2+1; i++ {
		b[i], b[l-i-1] = u[l-i-1], u[i]
	}
	return b
}
1274320
func (s *Subnet) Bits() (ones int, zeros int) {
	for _, b := range []byte(s.mask) {
		for i := uint(0); i < 8; i++ {
			if b&(1<<i) == 0 {
				zeros++
			} else {
				ones++
			}
		}
	}
	return
}
541526
func reverseBits(v, s uint) uint {
	var r uint

	// Since we aren't reversing all the bits in v (just the first s bits),
	// we only need the first bit of v instead of a full copy.
	r = v & 1
	s--

	for v >>= 1; v != 0; v >>= 1 {
		r <<= 1
		r |= v & 1
		s--
	}

	return r << s
}
943234
func flip(a *Container) *Container { // nolint: deadcode
	if a.isArray() {
		return flipArray(a)
	} else if a.isRun() {
		return flipRun(a)
	} else {
		return flipBitmap(a)
	}
}
437878
func (api *SwitchAPI) Include(key string) *SwitchAPI {
	api.include(key)
	return api
}