本文整理汇总了Golang中github.com/willf/bitset.BitSet.Test方法的典型用法代码示例。如果您正苦于以下问题:Golang BitSet.Test方法的具体用法?Golang BitSet.Test怎么用?Golang BitSet.Test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/willf/bitset.BitSet
的用法示例。
在下文中一共展示了BitSet.Test方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: firstClearBit
func firstClearBit(bs *bitset.BitSet) (uint, bool) {
for i := uint(0); i < bs.Len(); i++ {
if !bs.Test(i) {
return i, true
}
}
return 0, false
}
示例2: equalsBitSet
func equalsBitSet(a *bitset.BitSet, b *Bitmap) bool {
for i, e := a.NextSet(0); e; i, e = a.NextSet(i + 1) {
if !b.ContainsInt(int(i)) {
return false
}
}
i := b.Iterator()
for i.HasNext() {
if !a.Test(uint(i.Next())) {
return false
}
}
return true
}
示例3: requestRetransmit
func requestRetransmit(blocks []int, bs *bitset.BitSet, conn net.Conn, e Encoder, isRestart bool) {
if len(blocks) <= 0 {
return
}
var missingBlocks []int
if isRestart {
missingBlocks = blocks[0:1]
} else {
for _, b := range blocks {
if !bs.Test(uint(b)) {
missingBlocks = append(missingBlocks, b)
}
}
}
payload := Retransmit{IsRestart: isRestart, BlockNums: missingBlocks}
pkt := Packet{Type: RETRANSMIT, Payload: payload}
_, err := sendPacket(&pkt, conn, e)
if err != nil {
log.Println("Error sending retransmit blocks: " + err.Error())
}
}
示例4: equalsBitSet
func (p *smatPair) equalsBitSet(a *bitset.BitSet, b *Bitmap) bool {
for i, e := a.NextSet(0); e; i, e = a.NextSet(i + 1) {
if !b.ContainsInt(int(i)) {
fmt.Printf("in a bitset, not b bitmap, i: %d\n", i)
fmt.Printf(" a bitset: %s\n b bitmap: %s\n",
a.String(), b.String())
return false
}
}
i := b.Iterator()
for i.HasNext() {
v := i.Next()
if !a.Test(uint(v)) {
fmt.Printf("in b bitmap, not a bitset, v: %d\n", v)
fmt.Printf(" a bitset: %s\n b bitmap: %s\n",
a.String(), b.String())
return false
}
}
return true
}