本文整理汇总了Python中BitVector.rank_of_bit_set_at_index方法的典型用法代码示例。如果您正苦于以下问题:Python BitVector.rank_of_bit_set_at_index方法的具体用法?Python BitVector.rank_of_bit_set_at_index怎么用?Python BitVector.rank_of_bit_set_at_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector.rank_of_bit_set_at_index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: import BitVector [as 别名]
# 或者: from BitVector import rank_of_bit_set_at_index [as 别名]
print("Jaccard distance: " + str(bv1.jaccard_distance(bv2))) # 0.5
print("Hamming distance: " + str(bv1.hamming_distance(bv2))) # 4
print("\nTesting next_set_bit():")
bv = BitVector(bitstring='00000000000001')
print(bv.next_set_bit(5)) # 13
bv = BitVector(bitstring='000000000000001')
print(bv.next_set_bit(5)) # 14
bv = BitVector(bitstring='0000000000000001')
print(bv.next_set_bit(5)) # 15
bv = BitVector(bitstring='00000000000000001')
print(bv.next_set_bit(5)) # 16
print("\nTesting rank_of_bit_set_at_index():")
bv = BitVector(bitstring='01010101011100')
print(bv.rank_of_bit_set_at_index(10)) # 6
print("\nTesting is_power_of_2():")
bv = BitVector(bitstring='10000000001110')
print("int value: " + str(int(bv))) # 826
print(bv.is_power_of_2()) # False
print("\nTesting is_power_of_2_sparse():")
print(bv.is_power_of_2_sparse()) # False
print("\nTesting reverse():")
bv = BitVector(bitstring='0001100000000000001')
print("original bv: " + str(bv)) # 0001100000000000001
print("reversed bv: " + str(bv.reverse())) # 1000000000000011000
print("\nTesting Greatest Common Divisor (gcd):")
bv1 = BitVector(bitstring='01100110')