本文整理匯總了Python中sortedcontainers.SortedList._index方法的典型用法代碼示例。如果您正苦於以下問題:Python SortedList._index方法的具體用法?Python SortedList._index怎麽用?Python SortedList._index使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sortedcontainers.SortedList
的用法示例。
在下文中一共展示了SortedList._index方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_stress
# 需要導入模塊: from sortedcontainers import SortedList [as 別名]
# 或者: from sortedcontainers.SortedList import _index [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 _index [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()