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


Python BTree.add方法代码示例

本文整理汇总了Python中durus.btree.BTree.add方法的典型用法代码示例。如果您正苦于以下问题:Python BTree.add方法的具体用法?Python BTree.add怎么用?Python BTree.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在durus.btree.BTree的用法示例。


在下文中一共展示了BTree.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def get(self):
     bt = BTree()
     for j in range(10):
         bt.add(j)
     assert bt.get(2) == True
     assert bt.get(-1) == None
     assert bt.get(-1, 5) == 5
开发者ID:Schevo,项目名称:durus,代码行数:9,代码来源:utest_btree.py

示例2: test_delete_case_2c

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def test_delete_case_2c(self):
     bt = BTree(BNode)
     for j in 'abcdefghi':
         bt.add(j)
     assert bt.root.items == [('d', True)]
     del bt['d']
     assert len(bt) == bt.root.get_count()
开发者ID:ctismer,项目名称:durus,代码行数:9,代码来源:test_btree.py

示例3: clear

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def clear(self):
     bt = BTree()
     for j in range(10):
         bt.add(j)
     assert bt.has_key(2)
     bt.clear()
     assert not bt.has_key(2)
     assert bt.keys() == []
开发者ID:Schevo,项目名称:durus,代码行数:10,代码来源:utest_btree.py

示例4: find_extremes

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def find_extremes(self):
     bt = BTree()
     raises(AssertionError, bt.get_min_item)
     raises(AssertionError, bt.get_max_item)
     for j in range(100):
         bt.add(j)
     assert bt.get_min_item() == (0, True)
     assert bt.get_max_item() == (99, True)
开发者ID:Schevo,项目名称:durus,代码行数:10,代码来源:utest_btree.py

示例5: iter

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def iter(self):
     bt = BTree()
     for j in range(100):
         bt.add(j)
     assert list(bt) == list(bt.iterkeys())
     assert list(bt.iteritems()) == list(zip(bt, bt.itervalues()))
     assert list(bt.iterkeys()) == list(bt.keys())
     assert list(bt.itervalues()) == list(bt.values())
     assert list(bt.iteritems()) == list(bt.items())
开发者ID:Schevo,项目名称:durus,代码行数:11,代码来源:utest_btree.py

示例6: items_from

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def items_from(self):
     bt = BTree()
     for j in range(100):
         bt.add(j)
     for cutoff in (-1, 1, 50.1, 100, 102):
         assert (list([(x, y) for (x, y) in bt.items() if x >= cutoff]) ==
                 list(bt.items_from(cutoff)))
         assert (list([(x, y) for (x, y) in bt.items() if x > cutoff]) ==
                 list(bt.items_from(cutoff, closed=False)))
开发者ID:Schevo,项目名称:durus,代码行数:11,代码来源:utest_btree.py

示例7: search

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def search(self):
     bt = BTree(BNode)
     for j in range(100):
         bt.add(j)
     assert bt[1] == True
     try:
         assert bt[-1]
     except KeyError:
         pass
开发者ID:Schevo,项目名称:durus,代码行数:11,代码来源:utest_btree.py

示例8: _delete_case_3

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def _delete_case_3(self):
     bt = BTree(BNode)
     for j in range(100):
         bt.add(j)
     assert bt.root.items == [(31, True), (63, True)]
     assert [n.items for n in bt.root.nodes] == [
         [(15, True)], [(47, True)], [(79, True)]]
     assert [[n.items for n in node.nodes]
             for node in bt.root.nodes] == [
         [[(7, True)], [(23, True)]],
         [[(39, True)], [(55, True)]],
         [[(71, True)], [(87, True)]]]
     return bt
开发者ID:Schevo,项目名称:durus,代码行数:15,代码来源:utest_btree.py

示例9: test_iter

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def test_iter(self):
     bt = BTree()
     for j in range(100):
         bt.add(j)
     if hasattr(bt, 'iterkeys'):
         assert list(bt) == list(bt.iterkeys())
         assert list(bt.iteritems()) == list(zip(bt, bt.itervalues()))
         assert list(bt.iterkeys()) == list(bt.keys())
         assert list(bt.itervalues()) == list(bt.values())
         assert list(bt.iteritems()) == list(bt.items())
     else:
         assert list(bt) == list(bt.keys())
         assert list(bt.items()) == list(zip(bt, bt.values()))
开发者ID:ctismer,项目名称:durus,代码行数:15,代码来源:test_btree.py

示例10: items_backward_from

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def items_backward_from(self):
     bt = BTree()
     for j in range(100):
         bt.add(j)
     for cutoff in (-1, 1, 50.1, 100, 102):
         expect = list(reversed([(x, y) for (x, y) in bt.items()
                                 if x < cutoff]))
         got = list(bt.items_backward_from(cutoff))
         assert expect == got, (cutoff, expect, got)
         expect = list(reversed([(x, y) for (x, y) in bt.items()
                                 if x <= cutoff]))
         got = list(bt.items_backward_from(cutoff, closed=True))
         assert expect == got, (cutoff, expect, got)
开发者ID:Schevo,项目名称:durus,代码行数:15,代码来源:utest_btree.py

示例11: items_range

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [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

示例12: delete_case_2c

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def delete_case_2c(self):
     bt = BTree(BNode)
     for j in 'abcdefghi':
         bt.add(j)
     assert bt.root.items == [('d', True)]
     del bt['d']
开发者ID:Schevo,项目名称:durus,代码行数:8,代码来源:utest_btree.py

示例13: delete_case_2a

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def delete_case_2a(self):
     bt = BTree(BNode)
     for j in 'jklmoab':
         bt.add(j)
     del bt['k']
开发者ID:Schevo,项目名称:durus,代码行数:7,代码来源:utest_btree.py

示例14: reversed

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def reversed(self):
     bt = BTree()
     for j in range(100):
         bt.add(j)
     assert list(reversed(bt)) == list(reversed(list(bt)))
开发者ID:Schevo,项目名称:durus,代码行数:7,代码来源:utest_btree.py

示例15: has_key

# 需要导入模块: from durus.btree import BTree [as 别名]
# 或者: from durus.btree.BTree import add [as 别名]
 def has_key(self):
     bt = BTree()
     for j in range(10):
         bt.add(j)
     assert bt.has_key(2)
     assert not bt.has_key(-1)
开发者ID:Schevo,项目名称:durus,代码行数:8,代码来源:utest_btree.py


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