当前位置: 首页>>代码示例>>Python>>正文


Python BTree.items_range方法代码示例

本文整理汇总了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)
开发者ID:Schevo,项目名称:durus,代码行数:49,代码来源:utest_btree.py


注:本文中的durus.btree.BTree.items_range方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。