// CmpShift compares x and y*shift.
345503
func CmpShift(x, y, shift uint64) int {
	y1, y0 := Mul64(y, shift)
	if y1 != 0 {
		return -1
	}
	return Cmp(x, y0)
}
926180
func (e *executor) executeShiftShard(ctx context.Context, index string, c *pql.Call, shard uint64) (*Row, error) {
	n, _, err := c.IntArg("n")
	if err != nil {
		return nil, fmt.Errorf("executeShiftShard: %v", err)
	}

	if len(c.Children) == 0 {
		return nil, errors.New("Shift() requires an input row")
	} else if len(c.Children) > 1 {
		return nil, errors.New("Shift() only accepts a single row input")
	}

	row, err := e.executeBitmapCallShard(ctx, index, c.Children[0], shard)
	if err != nil {
		return nil, err
	}

	return row.Shift(n)
}
83819
func (ps Points) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}
956422
func (slice metricSlice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
810378
func (c *CMSketch) Copy() *CMSketch {
	if c == nil {
		return nil
	}
	tbl := make([][]uint32, c.depth)
	for i := range tbl {
		tbl[i] = make([]uint32, c.width)
		copy(tbl[i], c.table[i])
	}
	var topN map[uint64][]*TopNMeta
	if c.topN != nil {
		topN = make(map[uint64][]*TopNMeta)
		for h1, vals := range c.topN {
			newVals := make([]*TopNMeta, 0, len(vals))
			for _, val := range vals {
				newVal := TopNMeta{h2: val.h2, Count: val.Count, Data: make([]byte, len(val.Data))}
				copy(newVal.Data, val.Data)
				newVals = append(newVals, &newVal)
			}
			topN[h1] = newVals
		}
	}
	return &CMSketch{count: c.count, width: c.width, depth: c.depth, table: tbl, defaultValue: c.defaultValue, topN: topN}
}
555486
func shift(c *Container) (*Container, bool) {
	if c.isArray() {
		return shiftArray(c)
	} else if c.isRun() {
		return shiftRun(c)
	}
	return shiftBitmap(c)
}
225288
func MoveSmooth(x, y int, args ...interface{}) bool {
	cx := C.size_t(x)
	cy := C.size_t(y)

	var (
		mouseDelay = 10
		low        C.double
		high       C.double
	)

	if len(args) > 2 {
		mouseDelay = args[2].(int)
	}

	if len(args) > 1 {
		low = C.double(args[0].(float64))
		high = C.double(args[1].(float64))
	} else {
		low = 1.0
		high = 3.0
	}

	cbool := C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))

	return bool(cbool)
}
483363
func intSliceDiff(x, y []int) []int {
	var out []int

	for _, cX := range x {
		found := false
		for _, cY := range y {
			if cX == cY {
				found = true
				break
			}
		}
		if !found {
			out = append(out, cX)
		}
	}

	for _, cY := range y {
		found := false
		for _, cX := range x {
			if cY == cX {
				found = true
				break
			}
		}
		if !found {
			out = append(out, cY)
		}
	}

	return out
}
1270053
func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight {
	return &ShiftRight{
		FreeFloating: nil,
		Left:         Variable,
		Right:        Expression,
	}
}
925812
func (s Float64Slice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
22159
func (c *Cursor) Move(x int, y int) {
	fmt.Fprintf(c.Out, "\x1b[%d;%df", x, y)
}
1119607
func (a *ActDepend) shift() {
	if a.ended {
		return
	}

	if a.ind >= a.Size() {
		return
	}

	a.ind++
}
672509
func rightShift(slice []byte, num int) {
	for i := len(slice) - num - 1; i >= 0; i-- {
		slice[num+i] = slice[i]
	}

	for i := 0; i < num; i++ {
		slice[i] = 0
	}
}
1042765
func SliceShiftRight(s1 []byte, bits uint) []byte {
	l := len(s1)
	s := make([]byte, l)

	r := bits / 8
	rs := bits - r*8

	for i := 0; i < l; i++ {
		// relative index
		ri := i - int(r)
		bl := byte(0)
		if ri >= 1 {
			bl = s1[ri-1] << (8 - rs)
		}

		bu := byte(0)
		if ri >= 0 {
			bu = s1[ri] >> rs
		}
		s[i] = bl | bu
	}

	return s
}
680058
func (slice byTimestamp) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
234166
func (ps Points) XDifference(idxA, idxB int) float64 {
	return ps[idxA].X() - ps[idxB].X()
}
1160696
func (s *rowSegment) Shift() (*rowSegment, error) {
	//TODO deal with overflow
	data, err := s.data.Shift(1)
	if err != nil {
		return nil, errors.Wrap(err, "shifting roaring data")
	}

	return &rowSegment{
		data:  *data,
		shard: s.shard,
		n:     data.Count(),
	}, nil
}