change v0.0.2
This commit is contained in:
@@ -12,20 +12,11 @@ type AclBit int64
|
||||
func New(n ...NumBit) AclBit {
|
||||
var i64 AclBit
|
||||
for _, n0 := range n {
|
||||
i64 = SetTrue(i64, n0)
|
||||
i64.SetTrue(n0)
|
||||
}
|
||||
return i64
|
||||
}
|
||||
|
||||
// verytify Num bit (max range 0 - 62 , summary 63 bit)
|
||||
func veryNumBit(n NumBit) bool {
|
||||
if n >= 0 && n < 63 {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// unite slice int to int64
|
||||
func Unite(a ...AclBit) AclBit {
|
||||
var endacl AclBit
|
||||
@@ -37,25 +28,21 @@ func Unite(a ...AclBit) AclBit {
|
||||
}
|
||||
|
||||
// set acl bit in true
|
||||
func SetTrue(a AclBit, n NumBit) AclBit {
|
||||
func (a *AclBit) SetTrue(n NumBit) {
|
||||
if veryNumBit(n) {
|
||||
return a | (1 << n)
|
||||
*a = *a | (1 << n)
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// set acl bit in false
|
||||
func SetFalse(a AclBit, n NumBit) AclBit {
|
||||
func (a *AclBit) SetFalse(n NumBit) {
|
||||
if veryNumBit(n) {
|
||||
return a &^ (1 << n)
|
||||
*a = *a &^ (1 << n)
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// verify bit return true or false
|
||||
func Verify(a AclBit, n NumBit) bool {
|
||||
func (a AclBit) Verify(n NumBit) bool {
|
||||
if veryNumBit(n) {
|
||||
var msk AclBit = 1 << n
|
||||
if (a & msk) == msk {
|
||||
@@ -103,3 +90,12 @@ func Int64(i any) int64 {
|
||||
return i64
|
||||
}
|
||||
}
|
||||
|
||||
// verytify Num bit (max range 0 - 62 , summary 63 bit)
|
||||
func veryNumBit(n NumBit) bool {
|
||||
if n >= 0 && n < 63 {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user