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


Python FastRBTree.from_keys方法代码示例

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


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

示例1: open

# 需要导入模块: from bintrees import FastRBTree [as 别名]
# 或者: from bintrees.FastRBTree import from_keys [as 别名]
"""
setup_FastRBTree_ps = """
from __main__ import keys, crb_prev, crb_succ
"""

try:
    fp = open('testkeys.txt')
    keys = eval(fp.read())
    fp.close()
    bskeys = zip(keys, keys)
except IOError:
    print("create 'testkeys.txt' with profile_bintree.py\n")
    sys.exit()

ptree = PTree.from_keys(keys)
ftree = FTree.from_keys(keys)


def rb_prev():
    for key in keys:
        try:
            item = ptree.prev_item(key)
        except KeyError:
            pass


def rb_succ():
    for key in keys:
        try:
            item = ptree.succ_item(key)
        except KeyError:
开发者ID:Sprexatura,项目名称:bintrees,代码行数:33,代码来源:profile_prev_succ.py

示例2: crb_build

# 需要导入模块: from bintrees import FastRBTree [as 别名]
# 或者: from bintrees.FastRBTree import from_keys [as 别名]
def crb_build():
    tree = FastRBTree.from_keys(keys)
开发者ID:Sprexatura,项目名称:bintrees,代码行数:4,代码来源:profile_big_rbtree.py

示例3: range

# 需要导入模块: from bintrees import FastRBTree [as 别名]
# 或者: from bintrees.FastRBTree import from_keys [as 别名]
COUNT = 1
ITEMS = 2**22

setup_dict = """
from __main__ import dict_build_delete, dict_build, dict_search
"""
setup_FastRBTree = """
from __main__ import crb_build_delete, crb_build, crb_search
"""


keys = [k for k in range(ITEMS)]
shuffle(keys)

fastrbtree_searchtree = FastRBTree.from_keys(keys)
dict_searchtree = dict.fromkeys(keys)


def dict_build_delete():
    d = dict.fromkeys(keys)
    for key in keys:
        del d[key]


def crb_build_delete():
    tree = FastRBTree.from_keys(keys)
    for key in keys:
        del tree[key]

开发者ID:Sprexatura,项目名称:bintrees,代码行数:30,代码来源:profile_big_rbtree.py

示例4: crb_build_delete

# 需要导入模块: from bintrees import FastRBTree [as 别名]
# 或者: from bintrees.FastRBTree import from_keys [as 别名]
def crb_build_delete():
    tree = FastRBTree.from_keys(keys)
    for key in keys:
        del tree[key]
开发者ID:Sprexatura,项目名称:bintrees,代码行数:6,代码来源:profile_big_rbtree.py

示例5: open

# 需要导入模块: from bintrees import FastRBTree [as 别名]
# 或者: from bintrees.FastRBTree import from_keys [as 别名]
"""
setup_FastRBTree = """
from __main__ import crb_build_delete, crb_build, crb_search
"""

try:
    fp = open('testkeys.txt')
    keys = eval(fp.read())
    fp.close()
    bskeys = zip(keys, keys)
except IOError:
    print("create 'testkeys.txt' with profile_bintree.py\n")
    sys.exit()

py_searchtree = RBTree.from_keys(keys)
cy_searchtree = FastRBTree.from_keys(keys)


def rb_build_delete():
    tree = RBTree.from_keys(keys)
    for key in keys:
        del tree[key]


def crb_build_delete():
    tree = FastRBTree.from_keys(keys)
    for key in keys:
        del tree[key]


def rb_build():
开发者ID:Sprexatura,项目名称:bintrees,代码行数:33,代码来源:profile_rbtree.py


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