本文整理汇总了Python中sortedcontainers.SortedDict._check方法的典型用法代码示例。如果您正苦于以下问题:Python SortedDict._check方法的具体用法?Python SortedDict._check怎么用?Python SortedDict._check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sortedcontainers.SortedDict
的用法示例。
在下文中一共展示了SortedDict._check方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stress
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_stress(repeat=1000):
sdict = SortedDict((val, -val) for val in range(1000))
for rpt in range(repeat):
action = random.choice(actions)
action(sdict)
try:
sdict._check()
except AssertionError:
print(action)
raise
start_len = len(sdict)
while len(sdict) < 500:
key = random.randrange(0, 2000)
sdict[key] = -key
while len(sdict) > 2000:
key = random.randrange(0, 2000)
if key in sdict:
del sdict[key]
if start_len != len(sdict):
sdict._check()
示例2: test_setitem
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_setitem():
temp = SortedDict()
for pos, key in enumerate(string.ascii_lowercase):
temp[key] = pos
temp._check()
assert len(temp) == 26
for pos, key in enumerate(string.ascii_lowercase):
temp[key] = pos
temp._check()
assert len(temp) == 26
示例3: test_init
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_init():
sdict = SortedDict()
sdict._check()
sdict = SortedDict(load=17)
sdict._check()
sdict = SortedDict((val, -val) for val in range(10000))
sdict._check()
assert all(key == -val for key, val in sdict.iteritems())
sdict.clear()
sdict._check()
assert len(sdict) == 0
sdict = SortedDict.fromkeys(range(1000), None)
assert all(sdict[key] == None for key in range(1000))
示例4: test_delitem
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_delitem():
mapping = [(val, pos) for pos, val in enumerate(string.ascii_lowercase)]
temp = SortedDict(mapping)
del temp['a']
temp._check()
示例5: test_init_kwargs
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_init_kwargs():
temp = SortedDict(a=1, b=2)
assert len(temp) == 2
assert temp['a'] == 1
assert temp['b'] == 2
temp._check()
示例6: test_init_args
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_init_args():
temp = SortedDict([('a', 1), ('b', 2)])
assert len(temp) == 2
assert temp['a'] == 1
assert temp['b'] == 2
temp._check()
示例7: test_init
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_init():
temp = SortedDict()
temp._check()
示例8: test_init_key
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_init_key():
temp = SortedDict(negate)
assert temp.key == negate
temp._check()
示例9: test_init
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _check [as 别名]
def test_init():
temp = SortedDict()
assert temp.key is None
temp._check()