// Cmp returns the comparison result of two key.
// The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
504684
func (k Key) Cmp(another Key) int {
	return bytes.Compare(k, another)
}
400342
public static boolean cmp(byte[] a, byte[] b) {
		if(a.length != b.length) {
			return false;
		}
		for(int i = 0; i < a.length; i++) {
			if(a[i] != b[i]) {
				return false;
			}
		}
		return true;
	}
135389
func (v Version) Cmp(another Version) int {
	if v.Ver > another.Ver {
		return 1
	} else if v.Ver < another.Ver {
		return -1
	}
	return 0
}
378538
func In(column string) Cmp {
	return Cmp{
		op:     in,
		column: column,
		value:  param(column),
	}
}
1124528
func IntsChk(cmp Cmp, s []int, t ...int) bool {
	data := sort.IntSlice(append(s, t...))
	return cmp(data, len(s))
}
899899
func (r *Ruler) inequality(op int, actual, expected interface{}) bool {
	// need some variables for these deals
	ruleDebug("entered inequality comparison")
	var cmpStr [2]string
	var cmpUint [2]uint64
	var cmpInt [2]int64
	var cmpFloat [2]float64

	for idx, i := range []interface{}{actual, expected} {
		switch t := i.(type) {
		case uint8:
			cmpUint[idx] = uint64(t)
		case uint16:
			cmpUint[idx] = uint64(t)
		case uint32:
			cmpUint[idx] = uint64(t)
		case uint64:
			cmpUint[idx] = t
		case uint:
			cmpUint[idx] = uint64(t)
		case int8:
			cmpInt[idx] = int64(t)
		case int16:
			cmpInt[idx] = int64(t)
		case int32:
			cmpInt[idx] = int64(t)
		case int64:
			cmpInt[idx] = t
		case int:
			cmpInt[idx] = int64(t)
		case float32:
			cmpFloat[idx] = float64(t)
		case float64:
			cmpFloat[idx] = t
		case string:
			cmpStr[idx] = t
		default:
			ruleDebug("invalid type for inequality comparison")
			return false
		}
	}

	// whichever of these works, we're happy with
	// but if you're trying to compare a string to an int, oh well!
	switch op {
	case gt:
		return cmpStr[0] > cmpStr[1] ||
			cmpUint[0] > cmpUint[1] ||
			cmpInt[0] > cmpInt[1] ||
			cmpFloat[0] > cmpFloat[1]
	case gte:
		return cmpStr[0] >= cmpStr[1] ||
			cmpUint[0] >= cmpUint[1] ||
			cmpInt[0] >= cmpInt[1] ||
			cmpFloat[0] >= cmpFloat[1]
	case lt:
		return cmpStr[0] < cmpStr[1] ||
			cmpUint[0] < cmpUint[1] ||
			cmpInt[0] < cmpInt[1] ||
			cmpFloat[0] < cmpFloat[1]
	case lte:
		return cmpStr[0] <= cmpStr[1] ||
			cmpUint[0] <= cmpUint[1] ||
			cmpInt[0] <= cmpInt[1] ||
			cmpFloat[0] <= cmpFloat[1]
	}

	return false
}
906643
func GetCmpFunction(lhs, rhs Expression) CompareFunc {
	switch GetAccurateCmpType(lhs, rhs) {
	case types.ETInt:
		return CompareInt
	case types.ETReal:
		return CompareReal
	case types.ETDecimal:
		return CompareDecimal
	case types.ETString:
		return CompareString
	case types.ETDuration:
		return CompareDuration
	case types.ETDatetime, types.ETTimestamp:
		return CompareTime
	case types.ETJson:
		return CompareJSON
	}
	return nil
}
833727
func pow(a, b int) int {
	p := 1
	for b > 0 {
		if b&1 != 0 {
			p *= a
		}
		b >>= 1
		a *= a
	}
	return p
}
1311862
func StringsChk(cmp Cmp, s []string, t ...string) bool {
	data := sort.StringSlice(append(s, t...))
	return cmp(data, len(s))
}
178808
func verifyAud(aud string, cmp string, required bool) bool {
	if aud == "" {
		return !required
	}
	if subtle.ConstantTimeCompare([]byte(aud), []byte(cmp)) != 0 {
		return true
	} else {
		return false
	}
}
819690
func (a int64Amount) Cmp(b int64Amount) int {
	switch {
	case a.scale == b.scale:
		// compare only the unscaled portion
	case a.scale > b.scale:
		result, remainder, exact := divideByScaleInt64(b.value, a.scale-b.scale)
		if !exact {
			return a.AsDec().Cmp(b.AsDec())
		}
		if result == a.value {
			switch {
			case remainder == 0:
				return 0
			case remainder > 0:
				return -1
			default:
				return 1
			}
		}
		b.value = result
	default:
		result, remainder, exact := divideByScaleInt64(a.value, b.scale-a.scale)
		if !exact {
			return a.AsDec().Cmp(b.AsDec())
		}
		if result == b.value {
			switch {
			case remainder == 0:
				return 0
			case remainder > 0:
				return 1
			default:
				return -1
			}
		}
		a.value = result
	}

	switch {
	case a.value == b.value:
		return 0
	case a.value < b.value:
		return -1
	default:
		return 1
	}
}
423358
func cmpNumberNumberF(op string, a, b float64) bool {
	switch op {
	case "=":
		return a == b
	case ">":
		return a > b
	case "<":
		return a < b
	case ">=":
		return a >= b
	case "<=":
		return a <= b
	case "!=":
		return a != b
	}
	return false
}
868866
func DateCmp(db XODB, v0 time.Time, v1 time.Time) (int, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.date_cmp($1, $2)`

	// run query
	var ret int
	XOLog(sqlstr, v0, v1)
	err = db.QueryRow(sqlstr, v0, v1).Scan(&ret)
	if err != nil {
		return 0, err
	}

	return ret, nil
}
630302
func preCmp(a, b string) int {
	auint, auinterr := parseUint(a)
	buint, buinterr := parseUint(b)
	switch {
	case auinterr == nil && buinterr == nil:
		return uintCmp(auint, buint)
	case auinterr == nil && buinterr != nil:
		return -1
	case auinterr != nil && buinterr == nil:
		return +1
	}
	return strings.Compare(a, b)
}
147886
func Intersect(a, b [][]byte) [][]byte {
	n := len(b)
	if len(a) > len(b) {
		n = len(a)
	}
	other := make([][]byte, 0, n)

	for len(a) > 0 && len(b) > 0 {
		if cmp := bytes.Compare(a[0], b[0]); cmp == 0 {
			other, a, b = append(other, a[0]), a[1:], b[1:]
		} else if cmp == -1 {
			a = a[1:]
		} else {
			b = b[1:]
		}
	}
	return other
}
311822
func (p Path) Compare(other Path) int {
	i := 0
	for {
		switch {
		case len(other) == len(p) && i == len(p):
			return 0
		case i == len(other):
			return 1
		case i == len(p):
			return -1
		default:
			// We do *not* normalize Unicode here. CGit doesn't.
			// https://github.com/src-d/go-git/issues/1057
			cmp := strings.Compare(p[i].Name(), other[i].Name())
			if cmp != 0 {
				return cmp
			}
		}
		i++
	}
}
931850
func (x *Dec) Cmp(y *Dec) int {
	xx, yy := upscale(x, y)
	return xx.UnscaledBig().Cmp(yy.UnscaledBig())
}