本文整理汇总了Python中durus.btree.BTree.items_range方法的典型用法代码示例。如果您正苦于以下问题:Python BTree.items_range方法的具体用法?Python BTree.items_range怎么用?Python BTree.items_range使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类durus.btree.BTree
的用法示例。
在下文中一共展示了BTree.items_range方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: items_range
# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import items_range [as 别名]
def items_range(self):
bt = BTree()
for j in range(100):
bt.add(j)
lo = 0
hi = 40
for lo, hi in [(-1,10), (3, 9), (30, 200), (-10, 200)]:
expect = list([(x, y) for (x, y) in bt.items()
if lo <= x < hi])
got = list(bt.items_range(lo, hi))
assert expect == got, (lo, hi, expect, got)
expect = list([(x, y) for (x, y) in bt.items()
if lo < x < hi])
got = list(bt.items_range(lo, hi, closed_start=False))
assert expect == got, (lo, hi, expect, got)
expect = list([(x, y) for (x, y) in bt.items()
if lo < x <= hi])
got = list(bt.items_range(
lo, hi, closed_start=False, closed_end=True))
assert expect == got, (lo, hi, expect, got)
expect = list([(x, y) for (x, y) in bt.items()
if lo <= x <= hi])
got = list(bt.items_range(
lo, hi, closed_start=True, closed_end=True))
assert expect == got, (lo, hi, expect, got)
expect = list(reversed([(x, y) for (x, y) in bt.items()
if lo < x <= hi]))
got = list(bt.items_range(hi, lo))
assert expect == got, (hi, lo, expect, got)
expect = list(reversed([(x, y) for (x, y) in bt.items()
if lo <= x <= hi]))
got = list(bt.items_range(hi, lo, closed_end=True))
assert expect == got, (hi, lo, expect, got)
expect = list(reversed([(x, y) for (x, y) in bt.items()
if lo <= x < hi]))
got = list(bt.items_range(
hi, lo, closed_start=False, closed_end=True))
assert expect == got, (hi, lo, expect, got)
expect = list(reversed([(x, y) for (x, y) in bt.items()
if lo < x < hi]))
got = list(bt.items_range(
hi, lo, closed_start=False, closed_end=False))
assert expect == got, (hi, lo, expect, got)
expect = list(reversed([(x, y) for (x, y) in bt.items()
if lo <= x <= hi]))
got = list(bt.items_range(hi, lo, closed_end=True))
assert expect == got, (hi, lo, expect, got)