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


Python Name.compare方法代码示例

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


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

示例1: Delegation

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import compare [as 别名]
    class Delegation(object):
        """
        A DelegationSet.Delegation holds a preference number and delegation name.
        Create a new DelegationSet.Delegation with the given values.

        :param int preference: The preference number.
        :param Name name: The delegation name. This makes a copy of the name.
        """
        def __init__(self, preference, name):
            self._preference = preference
            self._name = Name(name)

        def getPreference(self):
            """
            Get the preference number.

            :return: The preference number.
            :rtype: int
            """
            return self._preference

        def getName(self):
            """
            Get the delegation name.

            :return: The delegation name. NOTE: You must not change the name
              object - if you need to change it then make a copy.
            :rtype: Name
            """
            return self._name

        def compare(self, other):
            """
            Compare this Delegation with other according to the ordering, based
            first on the preference number, then on the delegation name.

            :param DelegationSet.Delegation other: The other Delegation to
              compare with.
            :return: 0 If they compare equal, -1 if this Delegation comes before
              other in the ordering, or 1 if this Delegation comes after.
            :rtype: int
            """
            if self._preference < other._preference:
                return -1
            if self._preference > other._preference:
                return 1

            return self._name.compare(other._name)
开发者ID:,项目名称:,代码行数:50,代码来源:


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