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


Python bisect.insort_left方法代码示例

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


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

示例1: add_section

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def add_section(self, start_address, name, virt_size, real_size,
                    is_exec, is_data, is_bss, data):
        if is_exec or is_data:
            bisect.insort_left(self._sorted_sections, start_address)
        self._abs_sections[start_address] = SectionAbs(
                name,
                start_address,
                virt_size,
                real_size,
                is_exec,
                is_data,
                is_bss,
                data)


    # for elf 
开发者ID:plasma-disassembler,项目名称:plasma,代码行数:18,代码来源:binary.py

示例2: _update_tag_positions

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def _update_tag_positions(self, rule):
        """
        Update _tag_positions to reflect the changes to tags that are
        made by *rule*.
        """
        # Update the tag index.
        for pos in self._positions_by_rule[rule]:
            # Delete the old tag.
            old_tag_positions = self._tag_positions[rule.original_tag]
            old_index = bisect.bisect_left(old_tag_positions, pos)
            del old_tag_positions[old_index]
            # Insert the new tag.
            new_tag_positions = self._tag_positions[rule.replacement_tag]
            bisect.insort_left(new_tag_positions, pos) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:16,代码来源:brill_trainer.py

示例3: _order_cluster_tree

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def _order_cluster_tree(Z):
    """
    Return clustering nodes in bottom-up order by distance.

    Parameters
    ----------
    Z : scipy.cluster.linkage array
        The linkage matrix.

    Returns
    -------
    nodes : list
        A list of ClusterNode objects.
    """
    q = deque()
    tree = to_tree(Z)
    q.append(tree)
    nodes = []

    while q:
        node = q.popleft()
        if not node.is_leaf():
            bisect.insort_left(nodes, node)
            q.append(node.get_right())
            q.append(node.get_left())
    return nodes 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:28,代码来源:hierarchy.py

示例4: fillInSnpSlotsWithOverflowers

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def fillInSnpSlotsWithOverflowers(newPositions, totalPhysLen, overflowers):
    posH = {}
    for pos in newPositions:
        posH[pos] = 1
    for i in range(len(overflowers)):
        del newPositions[-1]
    for pos in reversed(range(1, totalPhysLen+1)):
        if pos not in posH:
            bisect.insort_left(newPositions, pos)
            overflowers.pop()
            if len(overflowers) == 0:
                break 
开发者ID:kr-colab,项目名称:diploSHIC,代码行数:14,代码来源:msTools.py

示例5: add_domain

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def add_domain(candidate, domains):
    '''
    Use binary search to add the new domain `candidate`
    to the candidate list `domains` so that `domains` remains a sorted list.
    '''
    bisect.insort_left(domains, candidate) 
开发者ID:oval-group,项目名称:PLNN-verification,代码行数:8,代码来源:branch_and_bound.py

示例6: _insort_call

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def _insort_call(self, call):
        # We want to insert the call in the appropriate time slot. A simple
        # bisect.insort_left() is not sufficient as the comparison of two
        # methods is not defined in Python 3.
        times = [c[0] for c in self._calls]
        index = bisect.bisect_left(times, call[0])
        self._calls.insert(index, call) 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:9,代码来源:testing.py

示例7: add

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def add(self, state: State) -> None:
        self.index_to_state[state.index] = state
        bisect.insort_left(self.ordered_index, state.index) 
开发者ID:hase-project,项目名称:hase,代码行数:5,代码来源:state.py

示例8: add_major

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def add_major(self, state: State) -> None:
        # NOTE: major means the interval stubs
        self.add(state)
        bisect.insort_left(self.major_index, state.index) 
开发者ID:hase-project,项目名称:hase,代码行数:6,代码来源:state.py

示例9: _order_cluster_tree

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def _order_cluster_tree(Z):
    """
    Returns clustering nodes in bottom-up order by distance.

    Parameters
    ----------
    Z : scipy.cluster.linkage array
        The linkage matrix.

    Returns
    -------
    nodes : list
        A list of ClusterNode objects.
    """
    q = deque()
    tree = to_tree(Z)
    q.append(tree)
    nodes = []

    while q:
        node = q.popleft()
        if not node.is_leaf():
            bisect.insort_left(nodes, node)
            q.append(node.get_right())
            q.append(node.get_left())
    return nodes 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:28,代码来源:hierarchy.py

示例10: _InsertTask

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def _InsertTask(self, task):
    """Insert a task into the dummy store, keeps lists sorted.

    Args:
      task: the new task.
    """
    eta = task.eta_usec()
    name = task.task_name()
    bisect.insort_left(self._sorted_by_eta, (eta, name, task))
    bisect.insort_left(self._sorted_by_name, (name, task)) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:12,代码来源:taskqueue_stub.py

示例11: _InsertTask

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def _InsertTask(self, task):
    """Insert a task into the store, keeps lists sorted.

    Args:
      task: the new task.
    """
    assert self._lock.locked()
    eta = task.eta_usec()
    name = task.task_name()
    bisect.insort_left(self._sorted_by_eta, (eta, name, task))
    if task.has_tag():
      bisect.insort_left(self._sorted_by_tag, (task.tag(), eta, name, task))
    bisect.insort_left(self._sorted_by_name, (name, task))
    self.task_name_archive.add(name) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:16,代码来源:taskqueue_stub.py

示例12: _PostponeTaskInsertOnly

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def _PostponeTaskInsertOnly(self, task, new_eta_usec):
    assert self._lock.locked()
    task.set_eta_usec(new_eta_usec)
    name = task.task_name()
    bisect.insort_left(self._sorted_by_eta, (new_eta_usec, name, task))
    if task.has_tag():
      tag = task.tag()
      bisect.insort_left(self._sorted_by_tag, (tag, new_eta_usec, name, task)) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:10,代码来源:taskqueue_stub.py

示例13: test_keyword_args

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def test_keyword_args(self):
        data = [10, 20, 30, 40, 50]
        self.assertEqual(bisect_left(a=data, x=25, lo=1, hi=3), 2)
        self.assertEqual(bisect_right(a=data, x=25, lo=1, hi=3), 2)
        self.assertEqual(bisect(a=data, x=25, lo=1, hi=3), 2)
        insort_left(a=data, x=25, lo=1, hi=3)
        insort_right(a=data, x=25, lo=1, hi=3)
        insort(a=data, x=25, lo=1, hi=3)
        self.assertEqual(data, [10, 20, 25, 25, 25, 30, 40, 50])

#============================================================================== 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:13,代码来源:test_bisect.py

示例14: test_vsBuiltinSort

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def test_vsBuiltinSort(self, n=500):
        from random import choice
        for insorted in (list(), UserList()):
            for i in xrange(n):
                digit = choice("0123456789")
                if digit in "02468":
                    f = insort_left
                else:
                    f = insort_right
                f(insorted, digit)
        self.assertEqual(sorted(insorted), insorted) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:13,代码来源:test_bisect.py

示例15: test_non_sequence

# 需要导入模块: import bisect [as 别名]
# 或者: from bisect import insort_left [as 别名]
def test_non_sequence(self):
        for f in (bisect_left, bisect_right, insort_left, insort_right):
            self.assertRaises(TypeError, f, 10, 10) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:5,代码来源:test_bisect.py


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