本文整理汇总了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()
示例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()
示例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
示例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
示例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()
示例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
示例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 == []
示例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()
示例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()
示例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()
示例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
示例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()
示例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]))
示例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()
示例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