當前位置: 首頁>>代碼示例>>Python>>正文


Python SortedList._check方法代碼示例

本文整理匯總了Python中sortedcontainers.SortedList._check方法的典型用法代碼示例。如果您正苦於以下問題:Python SortedList._check方法的具體用法?Python SortedList._check怎麽用?Python SortedList._check使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sortedcontainers.SortedList的用法示例。


在下文中一共展示了SortedList._check方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_setitem_extended_slice

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_setitem_extended_slice():
    slt = SortedList(range(0, 1000, 10), load=17)
    lst = list(range(0, 1000, 10))
    lst[10:90:10] = range(105, 905, 100)
    slt[10:90:10] = range(105, 905, 100)
    assert slt == lst
    slt._check()
開發者ID:adamchainz,項目名稱:sorted_containers,代碼行數:9,代碼來源:test_coverage_sortedlist.py

示例2: test_delitem

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_delitem():
    random.seed(0)
    slt = SortedList(range(100), load=17)
    while len(slt) > 0:
        pos = random.randrange(len(slt))
        del slt[pos]
        slt._check()
開發者ID:danbornside,項目名稱:sorted_containers,代碼行數:9,代碼來源:test_coverage_sortedlist.py

示例3: test_bisect_left

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_bisect_left():
    slt = SortedList()
    assert slt.bisect_left(0) == 0
    slt = SortedList(range(100), load=17)
    slt.update(range(100))
    slt._check()
    assert slt.bisect_left(50) == 100
    assert slt.bisect_left(200) == 200
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:10,代碼來源:test_coverage_sortedlist.py

示例4: test_bisect_right

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_bisect_right():
    slt = SortedList()
    assert slt.bisect_right(10) == 0
    slt = SortedList(range(100), load=17)
    slt.update(range(100))
    slt._check()
    assert slt.bisect_right(10) == 22
    assert slt.bisect_right(200) == 200
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:10,代碼來源:test_coverage_sortedlist.py

示例5: test_append

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_append():
    slt = SortedList(load=17)

    slt.append(0)

    for val in range(1, 1000):
        slt.append(val)
        slt._check()
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:10,代碼來源:test_coverage_sortedlist.py

示例6: test_bisect

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_bisect():
    slt = SortedList()
    assert slt.bisect(10) == 0
    slt = SortedList(range(100))
    slt._reset(17)
    slt.update(range(100))
    slt._check()
    assert slt.bisect(10) == 22
    assert slt.bisect(200) == 200
開發者ID:grantjenks,項目名稱:sorted_containers,代碼行數:11,代碼來源:test_coverage_sortedlist.py

示例7: test_delete

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_delete():
    slt = SortedList(range(20), load=4)
    slt._check()
    for val in range(20):
        slt.remove(val)
        slt._check()
    assert len(slt) == 0
    assert slt._maxes == []
    assert slt._lists == []
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:11,代碼來源:test_coverage_sortedlist.py

示例8: test_setitem

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_setitem():
    random.seed(0)
    slt = SortedList(range(0, 100, 10), load=4)

    values = list(enumerate(range(5, 105, 10)))
    random.shuffle(values)
    for pos, val in values:
        slt[pos] = val

    slt[-2] = 85
    slt._check()
開發者ID:adamchainz,項目名稱:sorted_containers,代碼行數:13,代碼來源:test_coverage_sortedlist.py

示例9: test_pop

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_pop():
    slt = SortedList(range(10), load=4)
    slt._check()
    assert slt.pop() == 9
    slt._check()
    assert slt.pop(0) == 0
    slt._check()
    assert slt.pop(-2) == 7
    slt._check()
    assert slt.pop(4) == 5
    slt._check()
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:13,代碼來源:test_coverage_sortedlist.py

示例10: test_update

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_update():
    slt = SortedList()

    slt.update(range(1000))
    assert all(tup[0] == tup[1] for tup in zip(slt, list(range(1000))))
    assert len(slt) == 1000
    slt._check()

    slt.update(range(10000))
    assert len(slt) == 11000
    slt._check()
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:13,代碼來源:test_coverage_sortedlist.py

示例11: test_count

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_count():
    slt = SortedList(load=7)

    assert slt.count(0) == 0

    for iii in range(100):
        for jjj in range(iii):
            slt.add(iii)
        slt._check()

    for iii in range(100):
        assert slt.count(iii) == iii
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:14,代碼來源:test_coverage_sortedlist.py

示例12: test_contains

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_contains():
    slt = SortedList()
    assert 0 not in slt

    slt.update(range(10000))

    for val in range(10000):
        assert val in slt

    assert 10000 not in slt

    slt._check()
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:14,代碼來源:test_coverage_sortedlist.py

示例13: test_remove

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_remove():
    slt = SortedList()

    assert slt.discard(0) == None
    assert len(slt) == 0
    slt._check()

    slt = SortedList([1, 2, 2, 2, 3, 3, 5], load=4)

    slt.remove(2)
    slt._check()

    assert all(tup[0] == tup[1] for tup in zip(slt, [1, 2, 2, 3, 3, 5]))
開發者ID:sbagri,項目名稱:sorted_containers,代碼行數:15,代碼來源:test_coverage_sortedlist.py

示例14: test_stress

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_stress(repeat=1000):
    slt = SortedList((random.random() for rpt in range(1000)))

    for rpt in range(repeat):
        action = random.choice(actions)
        action(slt)

        slt._check()

        while len(slt) > 2000:
            # Shorten the sortedlist. This maintains the "jaggedness"
            # of the sublists which helps coverage.
            pos = random.randrange(len(slt._maxes))
            del slt._maxes[pos]
            del slt._lists[pos]
            slt._len = sum(len(sublist) for sublist in slt._lists)
            slt._index = []
            slt._check()

    slt._check()

    stress_update(slt)

    while len(slt) > 0:
        pos = random.randrange(len(slt))
        del slt[pos]

    slt._check()
開發者ID:bag-of-projects,項目名稱:sorted_containers,代碼行數:30,代碼來源:test_stress_sortedlist.py

示例15: test_new

# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _check [as 別名]
def test_new():
    slt = SortedList(key=modulo)
    slt._check()

    assert isinstance(slt, SortedList)
    assert isinstance(slt, SortedListWithKey)
    assert type(slt) == SortedListWithKey

    slt = SortedListWithKey(key=modulo)
    slt._check()

    assert isinstance(slt, SortedList)
    assert isinstance(slt, SortedListWithKey)
    assert type(slt) == SortedListWithKey
開發者ID:adamchainz,項目名稱:sorted_containers,代碼行數:16,代碼來源:test_coverage_sortedlistwithkey_modulo.py


注:本文中的sortedcontainers.SortedList._check方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。