本文整理汇总了Python中sortedcontainers.SortedList._len方法的典型用法代码示例。如果您正苦于以下问题:Python SortedList._len方法的具体用法?Python SortedList._len怎么用?Python SortedList._len使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sortedcontainers.SortedList
的用法示例。
在下文中一共展示了SortedList._len方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stress
# 需要导入模块: from sortedcontainers import SortedList [as 别名]
# 或者: from sortedcontainers.SortedList import _len [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()
示例2: test_stress
# 需要导入模块: from sortedcontainers import SortedList [as 别名]
# 或者: from sortedcontainers.SortedList import _len [as 别名]
def test_stress(repeat=1000):
slt = SortedList((random.random() for rpt in range(1000)))
slt._reset(23)
for rpt in range(repeat):
action = random.choice(actions)
action(slt)
slt._check()
fourth = int(len(slt) / 4)
count = 0 if fourth == 0 else random.randrange(-fourth, fourth)
while count > 0:
slt.add(random.random())
count -= 1
while count < 0:
pos = random.randrange(len(slt))
del slt[pos]
count += 1
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()
slt._check()
stress_update(slt)
while len(slt) > 0:
pos = random.randrange(len(slt))
del slt[pos]
slt._check()
示例3: test_check
# 需要导入模块: from sortedcontainers import SortedList [as 别名]
# 或者: from sortedcontainers.SortedList import _len [as 别名]
def test_check():
slt = SortedList(range(10), load=4)
slt._len = 5
slt._check()
示例4: test_check
# 需要导入模块: from sortedcontainers import SortedList [as 别名]
# 或者: from sortedcontainers.SortedList import _len [as 别名]
def test_check():
slt = SortedList(range(10))
slt._reset(4)
slt._len = 5
with pytest.raises(AssertionError):
slt._check()