当前位置: 首页>>代码示例>>Python>>正文


Python SortedKeyList._reset方法代码示例

本文整理汇总了Python中sortedcontainers.SortedKeyList._reset方法的典型用法代码示例。如果您正苦于以下问题:Python SortedKeyList._reset方法的具体用法?Python SortedKeyList._reset怎么用?Python SortedKeyList._reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sortedcontainers.SortedKeyList的用法示例。


在下文中一共展示了SortedKeyList._reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_copy

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_copy():
    slt = SortedKeyList(range(100), key=modulo)
    slt._reset(7)
    two = slt.copy()
    slt.add(100)
    assert len(slt) == 101
    assert len(two) == 100
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:9,代码来源:test_coverage_sortedkeylist_modulo.py

示例2: test_delitem_slice

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_delitem_slice():
    slt = SortedKeyList(range(100), key=modulo)
    slt._reset(17)
    del slt[10:40:1]
    del slt[10:40:-1]
    del slt[10:40:2]
    del slt[10:40:-2]
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:9,代码来源:test_coverage_sortedkeylist_modulo.py

示例3: test_islice

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [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]
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:27,代码来源:test_coverage_sortedkeylist_negate.py

示例4: test_delitem

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_delitem():
    random.seed(0)
    slt = SortedKeyList(range(100), key=negate)
    slt._reset(17)
    while len(slt) > 0:
        del slt[random.randrange(len(slt))]
        slt._check()
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:9,代码来源:test_coverage_sortedkeylist_negate.py

示例5: test_copy_copy

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_copy_copy():
    import copy
    slt = SortedKeyList(range(100), key=negate)
    slt._reset(7)
    two = copy.copy(slt)
    slt.add(100)
    assert len(slt) == 101
    assert len(two) == 100
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:10,代码来源:test_coverage_sortedkeylist_negate.py

示例6: test_pickle

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_pickle():
    import pickle
    alpha = SortedKeyList(range(10000), key=negate)
    alpha._reset(500)
    beta = pickle.loads(pickle.dumps(alpha))
    assert alpha == beta
    assert alpha._key == beta._key
    assert alpha._load == 500
    assert beta._load == 1000
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:11,代码来源:test_coverage_sortedkeylist_negate.py

示例7: test_bisect_right

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [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
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:11,代码来源:test_coverage_sortedkeylist_modulo.py

示例8: test_eq

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [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
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:11,代码来源:test_coverage_sortedkeylist_negate.py

示例9: test_bisect

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [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
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:11,代码来源:test_coverage_sortedkeylist_negate.py

示例10: test_gte

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_gte():
    this = SortedKeyList(range(10), key=negate)
    this._reset(4)
    that = SortedKeyList(range(10), key=negate)
    that._reset(5)
    assert this >= that
    assert that >= this
    del this[-1]
    assert that >= this
    assert not (this >= that)
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:12,代码来源:test_coverage_sortedkeylist_negate.py

示例11: test_delete

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_delete():
    slt = SortedKeyList(range(20), key=modulo)
    slt._reset(4)
    slt._check()
    for val in range(20):
        slt.remove(val)
        slt._check()
    assert len(slt) == 0
    assert slt._maxes == []
    assert slt._lists == []
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:12,代码来源:test_coverage_sortedkeylist_modulo.py

示例12: test_op_add

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_op_add():
    this = SortedKeyList(range(10), key=modulo)
    this._reset(4)
    assert (this + this + this) == (this * 3)

    that = SortedKeyList(range(10), key=modulo)
    that._reset(4)
    that += that
    that += that
    assert that == (this * 4)
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:12,代码来源:test_coverage_sortedkeylist_modulo.py

示例13: test_pop

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_pop():
    slt = SortedKeyList(range(10), key=negate)
    slt._reset(4)
    slt._check()
    assert slt.pop() == 0
    slt._check()
    assert slt.pop(0) == 9
    slt._check()
    assert slt.pop(-2) == 2
    slt._check()
    assert slt.pop(4) == 4
    slt._check()
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:14,代码来源:test_coverage_sortedkeylist_negate.py

示例14: test_pop

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_pop():
    slt = SortedKeyList(range(10), key=modulo)
    slt._reset(4)
    slt._check()
    assert slt.pop() == 9
    slt._check()
    assert slt.pop(0) == 0
    slt._check()
    assert slt.pop(-2) == 7
    slt._check()
    assert slt.pop(4) == 5
    slt._check()
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:14,代码来源:test_coverage_sortedkeylist_modulo.py

示例15: test_count

# 需要导入模块: from sortedcontainers import SortedKeyList [as 别名]
# 或者: from sortedcontainers.SortedKeyList import _reset [as 别名]
def test_count():
    slt = SortedKeyList(key=negate)
    slt._reset(7)

    assert slt.count(0) == 0

    for iii in range(100):
        for jjj in range(iii):
            slt.add(iii)
        slt._check()

    for iii in range(100):
        assert slt.count(iii) == iii
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:15,代码来源:test_coverage_sortedkeylist_negate.py


注:本文中的sortedcontainers.SortedKeyList._reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。