Documentation
¶
Index ¶
- type BitSet
- func (b *BitSet) And(bitSets ...*BitSet) *BitSet
- func (b *BitSet) AndNot(bitSet ...*BitSet) *BitSet
- func (b *BitSet) Binary(sep string) string
- func (b *BitSet) Bytes() []byte
- func (b *BitSet) Clear()
- func (b *BitSet) Count(start, end int) int
- func (b *BitSet) Get(offset int) bool
- func (b *BitSet) Not() *BitSet
- func (b *BitSet) Or(bitSet ...*BitSet) *BitSet
- func (b *BitSet) Range(f func(offset int, truth bool) bool)
- func (b *BitSet) Set(offset int, value bool) (bool, error)
- func (b *BitSet) Size() int
- func (b *BitSet) String() string
- func (b *BitSet) Sub(start, end int) *BitSet
- func (b *BitSet) Xor(bitSet ...*BitSet) *BitSet
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitSet ¶
type BitSet struct {
// contains filtered or unexported fields
}
BitSet bit set
Example ¶
Output: false false true true true true true true true true false true true true true true
func NewFromHex ¶
NewFromHex creates a bit set object from hex string.
func (*BitSet) And ¶
And returns all the "AND" bit sets. Notes:
If the bitSets are empty, returns b.
func (*BitSet) AndNot ¶
AndNot returns all the "&^" bit sets. Notes:
If the bitSets are empty, returns b.
func (*BitSet) Binary ¶
Binary returns the bit set by binary type. Notes:
Paramter sep is the separator between chars.
func (*BitSet) Count ¶
Count counts the amount of bit set to 1 within the specified range of the bit set. Notes:
0 means the 1st bit, -1 means the bottom 1th bit, -2 means the bottom 2th bit and so on.
func (*BitSet) Get ¶
Get gets the bit bool value on the specified offset. Notes:
0 means the 1st bit, -1 means the bottom 1th bit, -2 means the bottom 2th bit and so on; If offset>=len(b.set), returns false.
func (*BitSet) Range ¶
Range calls f sequentially for each bit present in the bit set. If f returns false, range stops the iteration.
func (*BitSet) Set ¶
Set sets the bit bool value on the specified offset, and returns the value of before setting. Notes:
0 means the 1st bit, -1 means the bottom 1th bit, -2 means the bottom 2th bit and so on; If offset>=len(b.set), automatically grow the bit set; If the bit offset is out of the left range, returns error.
Click to show internal directories.
Click to hide internal directories.