當前位置: 首頁>>代碼示例>>Python>>正文


Python operator.iadd方法代碼示例

本文整理匯總了Python中operator.iadd方法的典型用法代碼示例。如果您正苦於以下問題:Python operator.iadd方法的具體用法?Python operator.iadd怎麽用?Python operator.iadd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在operator的用法示例。


在下文中一共展示了operator.iadd方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _reset

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import iadd [as 別名]
def _reset(self, load):
        """Reset sorted list load factor.

        The `load` specifies the load-factor of the list. The default load
        factor of 1000 works well for lists from tens to tens-of-millions of
        values. Good practice is to use a value that is the cube root of the
        list size. With billions of elements, the best load factor depends on
        your usage. It's best to leave the load factor at the default until you
        start benchmarking.

        See :doc:`implementation` and :doc:`performance-scale` for more
        information.

        Runtime complexity: `O(n)`

        :param int load: load-factor for sorted list sublists

        """
        values = reduce(iadd, self._lists, [])
        self._clear()
        self._load = load
        self._update(values) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:24,代碼來源:sortedlist.py

示例2: __add__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import iadd [as 別名]
def __add__(self, other):
        """Return new sorted list containing all values in both sequences.

        ``sl.__add__(other)`` <==> ``sl + other``

        Values in `other` do not need to be in sorted order.

        Runtime complexity: `O(n*log(n))`

        >>> sl1 = SortedList('bat')
        >>> sl2 = SortedList('cat')
        >>> sl1 + sl2
        SortedList(['a', 'a', 'b', 'c', 't', 't'])

        :param other: other iterable
        :return: new sorted list

        """
        values = reduce(iadd, self._lists, [])
        values.extend(other)
        return self.__class__(values) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:23,代碼來源:sortedlist.py

示例3: __mul__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import iadd [as 別名]
def __mul__(self, num):
        """Return new sorted list with `num` shallow copies of values.

        ``sl.__mul__(num)`` <==> ``sl * num``

        Runtime complexity: `O(n*log(n))`

        >>> sl = SortedList('abc')
        >>> sl * 3
        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])

        :param int num: count of shallow copies
        :return: new sorted list

        """
        values = reduce(iadd, self._lists, []) * num
        return self.__class__(values) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:19,代碼來源:sortedlist.py

示例4: __imul__

# 需要導入模塊: import operator [as 別名]
# 或者: from operator import iadd [as 別名]
def __imul__(self, num):
        """Update the sorted list with `num` shallow copies of values.

        ``sl.__imul__(num)`` <==> ``sl *= num``

        Runtime complexity: `O(n*log(n))`

        >>> sl = SortedList('abc')
        >>> sl *= 3
        >>> sl
        SortedList(['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'])

        :param int num: count of shallow copies
        :return: existing sorted list

        """
        values = reduce(iadd, self._lists, []) * num
        self._clear()
        self._update(values)
        return self 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:22,代碼來源:sortedlist.py


注:本文中的operator.iadd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。