CompareTo() 정적인 개인적인 메소드

static private CompareTo ( CodeContext context, object>.IDictionary left, object>.IDictionary right ) : int
context CodeContext
left object>.IDictionary
right object>.IDictionary
리턴 int
예제 #1
0
        public object __cmp__(CodeContext context, object other)
        {
            IDictionary <object, object> oth = other as IDictionary <object, object>;

            // CompareTo is allowed to throw (string, int, etc... all do it if they don't get a matching type)
            if (oth == null)
            {
                object len, iteritems;
                if (!PythonOps.TryGetBoundAttr(context, other, "__len__", out len) ||
                    !PythonOps.TryGetBoundAttr(context, other, "iteritems", out iteritems))
                {
                    return(NotImplementedType.Value);
                }

                // user-defined dictionary...
                int lcnt = Count;
                int rcnt = PythonContext.GetContext(context).ConvertToInt32(PythonOps.CallWithContext(context, len));

                if (lcnt != rcnt)
                {
                    return(lcnt > rcnt ? 1 : -1);
                }

                return(DictionaryOps.CompareToWorker(context, this, new List(PythonOps.CallWithContext(context, iteritems))));
            }

            CompareUtil.Push(this, oth);
            try {
                return(DictionaryOps.CompareTo(context, this, oth));
            } finally {
                CompareUtil.Pop(this, oth);
            }
        }
예제 #2
0
 public int __cmp__(CodeContext /*!*/ context, [NotNull] PythonDictionary /*!*/ other)
 {
     CompareUtil.Push(this, other);
     try {
         return(DictionaryOps.CompareTo(context, this, other));
     } finally {
         CompareUtil.Pop(this, other);
     }
 }