// Flip tells drone to flip
550509
func (d *Driver) Flip(direction FlipType) (err error) {
	buf, _ := d.createPacket(flipCommand, 0x70, 1)
	d.seq++
	binary.Write(buf, binary.LittleEndian, d.seq)
	binary.Write(buf, binary.LittleEndian, byte(direction))
	binary.Write(buf, binary.LittleEndian, CalculateCRC16(buf.Bytes()))

	_, err = d.cmdConn.Write(buf.Bytes())
	return
}
130328
func (versions Versions) Swap(i, j int) {
	versions[i], versions[j] = versions[j], versions[i]
}
590487
func exifOrientation(r io.Reader) (int, FlipDirection) {
	var (
		angle    int
		flipMode FlipDirection
	)
	ex, err := exif.Decode(r)
	if err != nil {
		imageDebug("No valid EXIF; will not rotate or flip.")
		return 0, 0
	}
	tag, err := ex.Get(exif.Orientation)
	if err != nil {
		imageDebug(`No "Orientation" tag in EXIF; will not rotate or flip.`)
		return 0, 0
	}
	orient, err := tag.Int(0)
	if err != nil {
		imageDebug(fmt.Sprintf("EXIF error: %v", err))
		return 0, 0
	}
	switch orient {
	case topLeftSide:
		// do nothing
	case topRightSide:
		flipMode = 2
	case bottomRightSide:
		angle = 180
	case bottomLeftSide:
		angle = 180
		flipMode = 2
	case leftSideTop:
		angle = -90
		flipMode = 2
	case rightSideTop:
		angle = -90
	case rightSideBottom:
		angle = 90
		flipMode = 2
	case leftSideBottom:
		angle = 90
	}
	return angle, flipMode
}
542957
func (ms *multiSorter) Swap(i, j int) {
	ms.pods[i], ms.pods[j] = ms.pods[j], ms.pods[i]
}
514702
func (a Affine) Rotate(angle float64) Affine {
	s, c := math.Sincos(angle)
	return a.Mul(Affine{
		+c, +s, +0,
		-s, +c, +0,
		+0, +0, +1,
	})
}
139647
func (s *Shuffler) Shuffle(data Interface) {
	rand.Shuffle(data.Len(), data.Swap)
}
506743
func (s *Shuffler) Shuffle(data Interface) {
	n := data.Len()
	for i := n - 1; i >= 0; i-- {
		j := (*rand.Rand)(s).Intn(i + 1)
		data.Swap(i, j)
	}
}
393524
func (g *Generator) FlipCoin(percent int) bool {
	switch {
	case percent > 100:
		percent = 100
	case percent < 0:
		percent = 0
	}
	return g.Percent() >= percent
}
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)
	}
}
1179481
func (it *Item) Rotations() int {
	for _, p := range it.Properties {
		if p, ok := p.(*bmff.ImageRotation); ok {
			return int(p.Angle)
		}
	}
	return 0
}
856480
func (l *FileLogger) rotate() error {
	oldFile := l.out
	file, err := doRotate(l.out.Name(), l.maxRotate)
	if err != nil {
		return fmt.Errorf("Error rotating logs: %s", err)
	}
	l.curLines = 0
	l.out = file
	oldFile.Close()
	return nil
}
235984
func Pop(h Interface) interface{} {
	n := h.Len() - 1
	h.Swap(n, 0)
	shuffleDown(h, 0, n)
	return h.Pop()
}
121748
func (u UUIDSlice) Swap(i, j int) {
	u[i], u[j] = u[j], u[i]
}
352329
func (array orderTabletsForSwap) Swap(i, j int) {
	array[i], array[j] = array[j], array[i]
}
974340
func FlipInt(cp CommitmentPayload, players []PlayerState, modulus int64) (int64, error) {
	prng, err := Flip(cp, players)
	if err != nil {
		return 0, err
	}
	return prng.Int(modulus), nil
}
178051
func rotate(data Interface, a, m, b int) {
	i := m - a
	j := b - m

	for i != j {
		if i > j {
			swapRange(data, m-i, m, j)
			i -= j
		} else {
			swapRange(data, m-i, m+j-i, i)
			j -= i
		}
	}
	// i == j
	swapRange(data, m-i, m, i)
}
965087
func (slice RevelHooks) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}