本文整理汇总了Python中sortedcontainers.SortedKeyList.update方法的典型用法代码示例。如果您正苦于以下问题:Python SortedKeyList.update方法的具体用法?Python SortedKeyList.update怎么用?Python SortedKeyList.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sortedcontainers.SortedKeyList
的用法示例。
在下文中一共展示了SortedKeyList.update方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_islice
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_islice():
return
slt = SortedKeyList(key=negate)
slt._reset(7)
assert [] == list(slt.islice())
values = sorted(range(53), key=negate)
slt.update(values)
for start in range(53):
for stop in range(53):
assert list(slt.islice(start, stop)) == values[start:stop]
for start in range(53):
for stop in range(53):
assert list(slt.islice(start, stop, reverse=True)) == values[start:stop][::-1]
for start in range(53):
assert list(slt.islice(start=start)) == values[start:]
assert list(slt.islice(start=start, reverse=True)) == values[start:][::-1]
for stop in range(53):
assert list(slt.islice(stop=stop)) == values[:stop]
assert list(slt.islice(stop=stop, reverse=True)) == values[:stop][::-1]
示例2: test_bisect_right
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_bisect_right():
slt = SortedKeyList(key=modulo)
assert slt.bisect_right(10) == 0
slt = SortedKeyList(range(100), key=modulo)
slt._reset(17)
slt.update(range(100))
slt._check()
assert slt.bisect_right(10) == 20
assert slt.bisect_right(0) == 20
示例3: test_eq
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_eq():
this = SortedKeyList(range(10), key=negate)
this._reset(4)
that = SortedKeyList(range(20), key=negate)
that._reset(4)
assert not (this == that)
that.clear()
that.update(range(10))
assert this == that
示例4: test_bisect
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_bisect():
slt = SortedKeyList(key=negate)
assert slt.bisect(10) == 0
slt = SortedKeyList(range(100), key=negate)
slt._reset(17)
slt.update(range(100))
slt._check()
assert slt.bisect(10) == 180
assert slt.bisect(0) == 200
示例5: test_update
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_update():
slt = SortedKeyList(key=modulo)
slt.update(range(1000))
assert all(tup[0] == tup[1] for tup in zip(slt, sorted(range(1000), key=modulo)))
assert len(slt) == 1000
slt._check()
slt.update(range(10000))
assert len(slt) == 11000
slt._check()
示例6: test_contains
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_contains():
slt = SortedKeyList(key=negate)
assert 0 not in slt
slt.update(range(10000))
for val in range(10000):
assert val in slt
assert 10000 not in slt
assert -1 not in slt
slt._check()
示例7: test_getitem
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_getitem():
random.seed(0)
slt = SortedKeyList(key=modulo)
slt._reset(17)
slt.add(5)
slt._build_index()
slt._check()
slt.clear()
lst = list(random.random() for rpt in range(100))
slt.update(lst)
lst.sort(key=modulo)
assert all(slt[idx] == lst[idx] for idx in range(100))
assert all(slt[idx - 99] == lst[idx - 99] for idx in range(100))
示例8: test_contains
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_contains():
slt = SortedKeyList(key=modulo)
slt._reset(7)
assert 0 not in slt
slt.update(range(100))
for val in range(100):
assert val in slt
assert 100 not in slt
slt._check()
slt = SortedKeyList(range(100), key=modulo)
slt._reset(4)
assert all(val not in slt for val in range(100, 200))
示例9: test_islice
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_islice():
sl = SortedKeyList(key=modulo)
sl._reset(7)
assert [] == list(sl.islice())
values = sorted(range(100), key=modulo)
sl.update(values)
for start in range(53):
for stop in range(53):
assert list(sl.islice(start, stop)) == values[start:stop]
for start in range(53):
for stop in range(53):
assert list(sl.islice(start, stop, reverse=True)) == values[start:stop][::-1]
for start in range(53):
assert list(sl.islice(start=start)) == values[start:]
assert list(sl.islice(start=start, reverse=True)) == values[start:][::-1]
for stop in range(53):
assert list(sl.islice(stop=stop)) == values[:stop]
assert list(sl.islice(stop=stop, reverse=True)) == values[:stop][::-1]
示例10: test_irange
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_irange():
slt = SortedKeyList(key=negate)
slt._reset(7)
assert [] == list(slt.irange())
values = list(range(53))
slt.update(values)
for start in range(53):
for end in range(start, 53):
assert list(slt.irange(end, start)) == values[start:(end + 1)][::-1]
assert list(slt.irange(end, start, reverse=True)) == values[start:(end + 1)]
for start in range(53):
for end in range(start, 53):
assert list(slt.irange(end, start, (True, False))) == values[(start + 1):(end + 1)][::-1]
for start in range(53):
for end in range(start, 53):
assert list(slt.irange(end, start, (False, True))) == values[start:end][::-1]
for start in range(53):
for end in range(start, 53):
assert list(slt.irange(end, start, (False, False))) == values[(start + 1):end][::-1]
for start in range(53):
assert list(slt.irange(start)) == values[:(start + 1)][::-1]
for end in range(53):
assert list(slt.irange(None, end, (True, False))) == values[(end + 1):][::-1]
assert list(slt.irange(inclusive=(False, False))) == values[::-1]
assert list(slt.irange(-1)) == []
assert list(slt.irange(None, -1, (True, False))) == values[::-1]
示例11: test_update
# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import update [as 别名]
def test_update():
slt = SortedKeyList(key=negate)
slt.update(range(1000))
assert len(slt) == 1000
slt._check()
slt.update(range(100))
assert len(slt) == 1100
slt._check()
slt.update(range(10000))
assert len(slt) == 11100
slt._check()
values = sorted((val for val in chain(range(100), range(1000), range(10000))), key=negate)
assert all(tup[0] == tup[1] for tup in zip(slt, values))