當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。