gitee.com/quant1x/num@v0.3.2/logic_equal.go (about)

     1  package num
     2  
     3  import (
     4  	"gitee.com/quant1x/num/x32"
     5  	"gitee.com/quant1x/num/x64"
     6  )
     7  
     8  // Equal 比较相等
     9  func Equal[T BaseType](x, y []T) []bool {
    10  	return BinaryOperations2[T, bool](x, y, x32.Eq, x64.Eq, __eq_go[T])
    11  }
    12  
    13  func __eq_go[T BaseType](x, y []T) []bool {
    14  	length := len(x)
    15  	d := make([]bool, length)
    16  	for i := 0; i < length; i++ {
    17  		if x[i] == y[i] {
    18  			d[i] = true
    19  		}
    20  	}
    21  	return d
    22  }
    23  
    24  // NotEqual 不相等
    25  func NotEqual[T BaseType](x, y []T) []bool {
    26  	return BinaryOperations2[T, bool](x, y, x32.Neq, x64.Neq, __neq_go[T])
    27  }
    28  
    29  func __neq_go[T BaseType](x, y []T) []bool {
    30  	length := len(x)
    31  	d := make([]bool, length)
    32  	for i := 0; i < length; i++ {
    33  		if x[i] != y[i] {
    34  			d[i] = true
    35  		}
    36  	}
    37  	return d
    38  }