本文整理汇总了Python中sortedcontainers.SortedSet._reset方法的典型用法代码示例。如果您正苦于以下问题:Python SortedSet._reset方法的具体用法?Python SortedSet._reset怎么用?Python SortedSet._reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sortedcontainers.SortedSet
的用法示例。
在下文中一共展示了SortedSet._reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_add():
temp = SortedSet(range(100))
temp._reset(7)
temp.add(100)
temp.add(90)
temp._check()
assert all(val == temp[val] for val in range(101))
示例2: test_delitem_slice
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_delitem_slice():
vals = list(range(100))
temp = SortedSet(vals)
temp._reset(7)
del vals[20:40:2]
del temp[20:40:2]
assert temp == set(vals)
示例3: test_copy
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_copy():
temp = SortedSet(range(100))
temp._reset(7)
that = temp.copy()
that.add(1000)
assert len(temp) == 100
assert len(that) == 101
示例4: test_symmetric_difference_update
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_symmetric_difference_update():
temp = SortedSet(range(0, 75))
temp._reset(7)
that = SortedSet(range(25, 100))
that._reset(9)
temp ^= that
assert all(temp[val] == val for val in range(25))
assert all(temp[val + 25] == (val + 75) for val in range(25))
示例5: test_pickle
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_pickle():
import pickle
alpha = SortedSet(range(10000), key=negate)
alpha._reset(500)
data = pickle.dumps(alpha)
beta = pickle.loads(data)
assert alpha == beta
assert alpha._key == beta._key
示例6: test_copy_copy
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_copy_copy():
import copy
temp = SortedSet(range(100))
temp._reset(7)
that = copy.copy(temp)
that.add(1000)
assert len(temp) == 100
assert len(that) == 101
示例7: test_delitem_key
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_delitem_key():
temp = SortedSet(range(100), key=modulo)
temp._reset(7)
values = sorted(range(100), key=modulo)
for val in range(10):
del temp[val]
del values[val]
assert list(temp) == list(values)
示例8: test_discard
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_discard():
temp = SortedSet(range(100))
temp._reset(7)
temp.discard(0)
temp.discard(99)
temp.discard(50)
temp.discard(1000)
temp._check()
assert len(temp) == 97
示例9: test_count
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_count():
temp = SortedSet(range(100))
temp._reset(7)
assert all(temp.count(val) == 1 for val in range(100))
assert temp.count(100) == 0
assert temp.count(0) == 1
temp.add(0)
assert temp.count(0) == 1
temp._check()
示例10: test_eq
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_eq():
alpha = SortedSet(range(100))
alpha._reset(7)
beta = SortedSet(range(100))
beta._reset(17)
assert alpha == beta
assert alpha == beta._set
beta.add(101)
assert not (alpha == beta)
示例11: test_union
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_union():
temp = SortedSet(range(0, 50))
temp._reset(7)
that = SortedSet(range(50, 100))
that._reset(9)
result = temp.union(that)
assert all(result[val] == val for val in range(100))
assert all(temp[val] == val for val in range(50))
assert all(that[val] == (val + 50) for val in range(50))
示例12: test_symmetric_difference
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_symmetric_difference():
temp = SortedSet(range(0, 75))
temp._reset(7)
that = SortedSet(range(25, 100))
that._reset(9)
result = temp.symmetric_difference(that)
assert all(result[val] == val for val in range(25))
assert all(result[val + 25] == (val + 75) for val in range(25))
assert all(temp[val] == val for val in range(75))
assert all(that[val] == (val + 25) for val in range(75))
示例13: test_xor
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_xor():
temp = SortedSet(range(0, 75))
temp._reset(7)
that = SortedSet(range(25, 100))
that._reset(9)
result = temp ^ that
assert all(result[val] == val for val in range(25))
assert all(result[val + 25] == (val + 75) for val in range(25))
assert all(temp[val] == val for val in range(75))
assert all(that[val] == (val + 25) for val in range(75))
示例14: test_ne
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_ne():
alpha = SortedSet(range(100))
alpha._reset(7)
beta = SortedSet(range(99))
beta._reset(17)
assert alpha != beta
beta.add(100)
assert alpha != beta
assert alpha != beta._set
assert alpha != list(range(101))
示例15: test_le_ge
# 需要导入模块: from sortedcontainers import SortedSet [as 别名]
# 或者: from sortedcontainers.SortedSet import _reset [as 别名]
def test_le_ge():
alpha = SortedSet(range(100))
alpha._reset(7)
beta = SortedSet(range(101))
beta._reset(17)
assert alpha <= beta
assert not (beta <= alpha)
assert alpha <= beta._set
assert beta >= alpha
assert not (alpha >= beta)
assert beta >= alpha._set