本文整理汇总了Python中sortedcontainers.SortedDict._reset方法的典型用法代码示例。如果您正苦于以下问题:Python SortedDict._reset方法的具体用法?Python SortedDict._reset怎么用?Python SortedDict._reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sortedcontainers.SortedDict
的用法示例。
在下文中一共展示了SortedDict._reset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pickle
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_pickle():
import pickle
alpha = SortedDict(negate, zip(range(10000), range(10000)))
alpha._reset(500)
beta = pickle.loads(pickle.dumps(alpha))
assert alpha == beta
assert alpha._key == beta._key
示例2: test_irange
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_irange():
mapping = [(val, pos) for pos, val in enumerate(string.ascii_lowercase)]
temp = SortedDict(mapping)
temp._reset(7)
for start in range(26):
for stop in range(start + 1, 26):
result = list(string.ascii_lowercase[start:stop])
assert list(temp.irange(result[0], result[-1])) == result
示例3: test_islice
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_islice():
mapping = [(val, pos) for pos, val in enumerate(string.ascii_lowercase)]
temp = SortedDict(mapping)
temp._reset(7)
for start in range(30):
for stop in range(30):
assert list(temp.islice(start, stop)) == list(string.ascii_lowercase[start:stop])
示例4: test_irange_key
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_irange_key():
temp = SortedDict(modulo, ((val, val) for val in range(100)))
temp._reset(7)
values = sorted(range(100), key=modulo)
for start in range(10):
for stop in range(start, 10):
result = list(temp.irange_key(start, stop))
assert result == values[(start * 10):((stop + 1) * 10)]
示例5: test_init
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_init():
sdict = SortedDict()
sdict._check()
sdict = SortedDict()
sdict._reset(17)
sdict._check()
sdict = SortedDict((val, -val) for val in range(10000))
sdict._check()
assert all(key == -val for key, val in sdict.items())
sdict.clear()
sdict._check()
assert len(sdict) == 0
sdict = SortedDict.fromkeys(range(1000), None)
assert all(sdict[key] == None for key in range(1000))
示例6: test_iter_key
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_iter_key():
temp = SortedDict(negate, ((val, val) for val in range(100)))
temp._reset(7)
assert all(lhs == rhs for lhs, rhs in zip(temp, reversed(range(100))))
示例7: test_bisect_key2
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_bisect_key2():
temp = SortedDict(modulo, ((val, val) for val in range(100)))
temp._reset(7)
assert all(temp.bisect_key(val) == ((val % 10) + 1) * 10 for val in range(10))
assert all(temp.bisect_key_right(val) == ((val % 10) + 1) * 10 for val in range(10))
assert all(temp.bisect_key_left(val) == (val % 10) * 10 for val in range(10))
示例8: test_index_key
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_index_key():
temp = SortedDict(negate, ((val, val) for val in range(100)))
temp._reset(7)
assert all(temp.index(val) == (99 - val) for val in range(100))
示例9: test_reversed_key
# 需要导入模块: from sortedcontainers import SortedDict [as 别名]
# 或者: from sortedcontainers.SortedDict import _reset [as 别名]
def test_reversed_key():
temp = SortedDict(modulo, ((val, val) for val in range(100)))
temp._reset(7)
values = sorted(range(100), key=modulo)
assert all(lhs == rhs for lhs, rhs in zip(reversed(temp), reversed(values)))