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


C# DataObject.CompareTo方法代码示例

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


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

示例1: HighestSearch

        /// <summary>
        /// Searches for a given <see cref="DataObject"/> (<paramref name="ob"/>) in the 
        /// row list between the two bounds.
        /// </summary>
        /// <param name="ob"></param>
        /// <param name="list"></param>
        /// <param name="lower"></param>
        /// <param name="higher"></param>
        /// <remarks>
        /// This returns the place to insert ob into the vector, it should not be used to 
        /// determine if <paramref name="ob"/> is in the list or not.
        /// </remarks>
        /// <returns>
        /// This will return the highest row of the set of values that are equal to <paramref name="ob"/>.
        /// </returns>
        private long HighestSearch(DataObject ob, IList<long> list, long lower, long higher)
        {
            if ((higher - lower) <= 5) {
                // Start from the bottom up until we find the highest val
                for (long i = higher; i >= lower; --i) {
                    int res = ob.CompareTo(GetCellContents(list[(int)i]));
                    if (res >= 0)
                        return i + 1;
                }
                // Didn't find return lowest
                return lower;
            }

            long mid = (lower + higher) / 2;
            int compResult = ob.CompareTo(GetCellContents(list[(int)mid]));

            if (compResult == 0)
                // We know the bottom is between 'mid' and 'higher'
                return HighestSearch(ob, list, mid, higher);

            if (compResult < 0)
                return HighestSearch(ob, list, lower, mid - 1);

            return HighestSearch(ob, list, mid + 1, higher);
        }
开发者ID:kaktusan,项目名称:plsqlparser,代码行数:40,代码来源:BlindSearch.cs

示例2: HighestSearch

        private int HighestSearch(DataObject ob, IList<int> list, int lower, int higher)
        {
            if ((higher - lower) <= 5) {
                // Start from the bottom up until we find the highest val
                for (var i = higher; i >= lower; --i) {
                    int res = ob.CompareTo(GetValue(list[i]));
                    if (res >= 0)
                        return i + 1;
                }
                // Didn't find return lowest
                return lower;
            }

            var mid = (lower + higher)/2;
            int compResult = ob.CompareTo(GetValue(list[mid]));

            if (compResult == 0)
                // We know the bottom is between 'mid' and 'higher'
                return HighestSearch(ob, list, mid, higher);

            if (compResult < 0)
                return HighestSearch(ob, list, lower, mid - 1);

            return HighestSearch(ob, list, mid + 1, higher);
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:25,代码来源:BlindSearchIndex.cs

示例3: IntersectOn

        private static IndexRange IntersectOn(IndexRange range, SqlExpressionType op, DataObject value, bool nullCheck)
        {
            var start = range.StartValue;
            var startPosition = range.StartOffset;
            var end = range.EndValue;
            var endPosition = range.EndOffset;

            bool inclusive = op == SqlExpressionType.Is ||
                             op == SqlExpressionType.Equal ||
                             op == SqlExpressionType.GreaterOrEqualThan ||
                             op == SqlExpressionType.SmallerOrEqualThan;

            if (op == SqlExpressionType.Is ||
                op == SqlExpressionType.Equal ||
                op == SqlExpressionType.GreaterThan ||
                op == SqlExpressionType.GreaterOrEqualThan) {
                // With this operator, NULL values must return null.
                if (nullCheck && value.IsNull) {
                    return IndexRange.Null;
                }

                if (start.Equals(IndexRange.FirstInSet)) {
                    start = value;
                    startPosition = inclusive ? RangeFieldOffset.FirstValue : RangeFieldOffset.AfterLastValue;
                } else {
                    int c = value.CompareTo(start);
                    if ((c == 0 && startPosition == RangeFieldOffset.FirstValue) || c > 0) {
                        start = value;
                        startPosition = inclusive ? RangeFieldOffset.FirstValue : RangeFieldOffset.AfterLastValue;
                    }
                }
            }

            if (op == SqlExpressionType.Is ||
                op == SqlExpressionType.Equal ||
                op == SqlExpressionType.SmallerThan ||
                op == SqlExpressionType.SmallerOrEqualThan) {
                // With this operator, NULL values must return null.
                if (nullCheck && value.IsNull) {
                    return IndexRange.Null;
                }

                // If start is first in set, then we have to change it to after NULL
                if (nullCheck && start.Equals(IndexRange.FirstInSet)) {
                    start = DataObject.Null();
                    startPosition = RangeFieldOffset.AfterLastValue;
                }

                if (end.Equals(IndexRange.LastInSet)) {
                    end = value;
                    endPosition = inclusive ? RangeFieldOffset.LastValue : RangeFieldOffset.BeforeFirstValue;
                } else {
                    int c = value.CompareTo(end);
                    if ((c == 0 && endPosition == RangeFieldOffset.LastValue) || c < 0) {
                        end = value;
                        endPosition = inclusive ? RangeFieldOffset.LastValue : RangeFieldOffset.BeforeFirstValue;
                    }
                }
            }

            // If start and end are not null types (if either are, then it means it
            // is a placeholder value meaning start or end of set).
            if (!start.Equals(IndexRange.FirstInSet) &&
                !end.Equals(IndexRange.LastInSet)) {
                // If start is higher than end, return null
                int c = start.CompareTo(end);
                if ((c == 0 && (startPosition == RangeFieldOffset.AfterLastValue ||
                                endPosition == RangeFieldOffset.BeforeFirstValue)) ||
                    c > 0) {
                    return IndexRange.Null;
                }
            }

            // The new intersected range
            return new IndexRange(startPosition, start, endPosition, end);
        }
开发者ID:ArsenShnurkov,项目名称:deveeldb,代码行数:76,代码来源:IndexRangeSet.cs

示例4: IntersectRange

        /// <summary>
        /// Intersects the given SelectableRange object with the given operator and
        /// value constraint.
        /// </summary>
        /// <remarks>
        /// <b>Note</b>: This does not work with the <c>&lt;&gt;</c> operator 
        /// which must be handled another way.
        /// </remarks>
        private static SelectableRange IntersectRange(SelectableRange range, Operator op, DataObject val, bool nullCheck)
        {
            DataObject start = range.Start;
            RangePosition startPosition = range.StartPosition;
            DataObject end = range.End;
            RangePosition endPosition = range.EndPosition;

            bool inclusive = op.IsEquivalent(Operator.Is) ||
                             op.IsEquivalent(Operator.Equal) ||
                             op.IsEquivalent(Operator.GreaterOrEqual) ||
                             op.IsEquivalent(Operator.SmallerOrEqual);

            if (op.IsEquivalent(Operator.Is) ||
                op.IsEquivalent(Operator.Equal) ||
                op.IsEquivalent(Operator.Greater) ||
                op.IsEquivalent(Operator.GreaterOrEqual)) {
                // With this operator, NULL values must return null.
                if (nullCheck && val.IsNull) {
                    return null;
                }

                if (start == SelectableRange.FirstInSet) {
                    start = val;
                    startPosition = inclusive
                                        ? RangePosition.FirstValue
                                        : RangePosition.AfterLastValue;
                } else {
                    int c = val.CompareTo(start);
                    if ((c == 0 && startPosition == RangePosition.FirstValue) || c > 0) {
                        start = val;
                        startPosition = inclusive
                                            ? RangePosition.FirstValue
                                            : RangePosition.AfterLastValue;
                    }
                }
            }
            if (op.IsEquivalent(Operator.Is) ||
                op.IsEquivalent(Operator.Equal) ||
                op.IsEquivalent(Operator.Smaller) ||
                op.IsEquivalent(Operator.SmallerOrEqual)) {
                // With this operator, NULL values must return null.
                if (nullCheck && val.IsNull) {
                    return null;
                }

                // If start is first in set, then we have to change it to after NULL
                if (nullCheck && start == SelectableRange.FirstInSet) {
                    start = DataObject.Null;
                    startPosition = RangePosition.AfterLastValue;
                }

                if (end == SelectableRange.LastInSet) {
                    end = val;
                    endPosition = inclusive
                        ? RangePosition.LastValue
                        : RangePosition.BeforeFirstValue;
                } else {
                    int c = val.CompareTo(end);
                    if ((c == 0 && endPosition == RangePosition.LastValue) || c < 0) {
                        end = val;
                        endPosition = inclusive
                            ? RangePosition.LastValue
                            : RangePosition.BeforeFirstValue;
                    }
                }
            }

            // If start and end are not null types (if either are, then it means it
            // is a placeholder value meaning start or end of set).
            if (start != SelectableRange.FirstInSet &&
                end != SelectableRange.LastInSet) {
                // If start is higher than end, return null
                int c = start.CompareTo(end);
                if ((c == 0 && (startPosition == RangePosition.AfterLastValue ||
                                endPosition == RangePosition.BeforeFirstValue)) ||
                    c > 0) {
                    return null;
                }
            }

            // The new intersected range
            return new SelectableRange(startPosition, start, endPosition, end);
        }
开发者ID:kaktusan,项目名称:plsqlparser,代码行数:91,代码来源:SelectableRangeSet.cs


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