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


C# Name.compare方法代码示例

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


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

示例1: testCompare

        public void testCompare()
        {
            Name.Component c7f = new Name("/%7F").get(0);
            Name.Component c80 = new Name("/%80").get(0);
            Name.Component c81 = new Name("/%81").get(0);

            Assert.AssertTrue("%81 should be greater than %80", c81.compare(c80) > 0);
            Assert.AssertTrue("%80 should be greater than %7f", c80.compare(c7f) > 0);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:9,代码来源:TestNameComponentMethods.cs

示例2: matches

        /// <summary>
        /// Check if the component matches any of the exclude criteria.
        /// </summary>
        ///
        /// <param name="component">The name component to check.</param>
        /// <returns>True if the component matches any of the exclude criteria,
        /// otherwise false.</returns>
        public bool matches(Name.Component component)
        {
            for (int i = 0; i < entries_.Count; ++i) {
                if (get(i).getType() == net.named_data.jndn.Exclude.Type.ANY) {
                    Exclude.Entry  lowerBound = null;
                    if (i > 0)
                        lowerBound = get(i - 1);

                    // Find the upper bound, possibly skipping over multiple ANY in a row.
                    int iUpperBound;
                    Exclude.Entry  upperBound = null;
                    for (iUpperBound = i + 1; iUpperBound < entries_.Count; ++iUpperBound) {
                        if (get(iUpperBound).getType() == net.named_data.jndn.Exclude.Type.COMPONENT) {
                            upperBound = get(iUpperBound);
                            break;
                        }
                    }

                    // If lowerBound != null, we already checked component equals lowerBound on the last pass.
                    // If upperBound != null, we will check component equals upperBound on the next pass.
                    if (upperBound != null) {
                        if (lowerBound != null) {
                            if (component.compare(lowerBound.getComponent()) > 0
                                    && component.compare(upperBound.getComponent()) < 0)
                                return true;
                        } else {
                            if (component.compare(upperBound.getComponent()) < 0)
                                return true;
                        }

                        // Make i equal iUpperBound on the next pass.
                        i = iUpperBound - 1;
                    } else {
                        if (lowerBound != null) {
                            if (component.compare(lowerBound.getComponent()) > 0)
                                return true;
                        } else
                            // entries_ has only ANY.
                            return true;
                    }
                } else {
                    if (component.equals(get(i).getComponent()))
                        return true;
                }
            }

            return false;
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:55,代码来源:Exclude.cs

示例3: excludeRange

        /// <summary>
        /// Exclude all components in the range beginning at "from" and ending at "to".
        /// </summary>
        ///
        /// <param name="exclude">The Exclude object to update.</param>
        /// <param name="from">The first component in the exclude range.</param>
        /// <param name="to">The last component in the exclude range.</param>
        private static void excludeRange(Exclude exclude, Name.Component from,
				Name.Component to)
        {
            if (from.compare(to) >= 0) {
                if (from.compare(to) == 0)
                    throw new Exception(
                            "excludeRange: from == to. To exclude a single component, sue excludeOne.");
                else
                    throw new Exception(
                            "excludeRange: from must be less than to. Invalid range: ["
                                    + from.toEscapedString() + ", "
                                    + to.toEscapedString() + "]");
            }

            ArrayList entries = getExcludeEntries(exclude);

            int iNewFrom;
            int iFoundFrom = findEntryBeforeOrAt(entries, from);
            if (iFoundFrom < 0) {
                // There is no entry before "from" so insert at the beginning.
                entries.Insert(0, new Producer.ExcludeEntry (from, true));
                iNewFrom = 0;
            } else {
                Producer.ExcludeEntry  foundFrom = (Producer.ExcludeEntry ) entries[iFoundFrom];

                if (!foundFrom.anyFollowsComponent_) {
                    if (foundFrom.component_.equals(from)) {
                        // There is already an entry with "from", so just set the "ANY" flag.
                        foundFrom.anyFollowsComponent_ = true;
                        iNewFrom = iFoundFrom;
                    } else {
                        // Insert following the entry before "from".
                        entries.Insert(iFoundFrom + 1, new Producer.ExcludeEntry (from, true));
                        iNewFrom = iFoundFrom + 1;
                    }
                } else
                    // The entry before "from" already has an "ANY" flag, so do nothing.
                    iNewFrom = iFoundFrom;
            }

            // We have at least one "from" before "to", so we know this will find an entry.
            int iFoundTo = findEntryBeforeOrAt(entries, to);
            Producer.ExcludeEntry  foundTo = (Producer.ExcludeEntry ) entries[iFoundTo];
            if (iFoundTo == iNewFrom)
                // Insert the "to" immediately after the "from".
                entries.Insert(iNewFrom + 1, new Producer.ExcludeEntry (to, false));
            else {
                int iRemoveEnd;
                if (!foundTo.anyFollowsComponent_) {
                    if (foundTo.component_.equals(to))
                        // The "to" entry already exists. Remove up to it.
                        iRemoveEnd = iFoundTo;
                    else {
                        // Insert following the previous entry, which will be removed.
                        entries.Insert(iFoundTo + 1, new Producer.ExcludeEntry (to, false));
                        iRemoveEnd = iFoundTo + 1;
                    }
                } else
                    // "to" follows a component which is already followed by "ANY", meaning
                    // the new range now encompasses it, so remove the component.
                    iRemoveEnd = iFoundTo + 1;

                // Remove intermediate entries since they are inside the range.
                int iRemoveBegin = iNewFrom + 1;
                int nRemoveNeeded = iRemoveEnd - iRemoveBegin;
                for (int i = 0; i < nRemoveNeeded; ++i)
                    ILOG.J2CsMapping.Collections.Collections.RemoveAt(entries,iRemoveBegin);
            }

            setExcludeEntries(exclude, entries);
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:78,代码来源:Producer.cs


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