mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-05-24 05:09:09 -04:00
bitmask
This commit is contained in:
21
common/bitmask/byte.go
Normal file
21
common/bitmask/byte.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package bitmask
|
||||
|
||||
// Byte is a bitmask in byte.
|
||||
type Byte byte
|
||||
|
||||
// Has returns true if this bitmask contains another bitmask.
|
||||
func (b Byte) Has(bb Byte) bool {
|
||||
return (b & bb) != 0
|
||||
}
|
||||
|
||||
func (b *Byte) Add(bb Byte) {
|
||||
*b |= bb
|
||||
}
|
||||
|
||||
func (b *Byte) Clear(bb Byte) {
|
||||
*b &= ^bb
|
||||
}
|
||||
|
||||
func (b *Byte) Toggle(bb Byte) {
|
||||
*b ^= bb
|
||||
}
|
||||
Reference in New Issue
Block a user