static private CompareTo ( CodeContext context, object>.IDictionary | ||
context | CodeContext | |
left | object>.IDictionary | |
right | object>.IDictionary | |
return | int |
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); } }
public int __cmp__(CodeContext /*!*/ context, [NotNull] PythonDictionary /*!*/ other) { CompareUtil.Push(this, other); try { return(DictionaryOps.CompareTo(context, this, other)); } finally { CompareUtil.Pop(this, other); } }