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); } }
internal static int CompareToWorker(CodeContext /*!*/ context, IDictionary <object, object> left, List ritems) { List litems = DictionaryOps.items(left); litems.sort(context); ritems.sort(context); return(litems.CompareToWorker(ritems)); }
public int __cmp__(CodeContext /*!*/ context, [NotNull] PythonDictionary /*!*/ other) { CompareUtil.Push(this, other); try { return(DictionaryOps.CompareTo(context, this, other)); } finally { CompareUtil.Pop(this, other); } }
bool IAttributesCollection.TryGetValue(SymbolId name, out object value) { if (GetType() != typeof(PythonDictionary) && DictionaryOps.TryGetValueVirtual(DefaultContext.Default, this, SymbolTable.IdToString(name), ref DefaultGetItem, out value)) { return(true); } // call Dict.TryGetValue to get the real value. return(_storage.TryGetValue(SymbolTable.IdToString(name), out value)); }
internal static int CompareTo(CodeContext /*!*/ context, IDictionary <object, object> left, IDictionary <object, object> right) { int lcnt = left.Count; int rcnt = right.Count; if (lcnt != rcnt) { return(lcnt > rcnt ? 1 : -1); } List ritems = DictionaryOps.items(right); return(CompareToWorker(context, left, ritems)); }
public virtual string /*!*/ __repr__(CodeContext /*!*/ context) { return(DictionaryOps.__repr__(context, this)); }
public void update(CodeContext /*!*/ context, object b) { DictionaryOps.update(context, this, b); }
public void update(CodeContext /*!*/ context, object b, [ParamDictionary] IDictionary <object, object> f) { DictionaryOps.update(context, this, b); DictionaryOps.update(context, this, f); }
public object setdefault(object key) { return(DictionaryOps.setdefault(this, key)); }
public object setdefault(object key, object defaultValue) { return(DictionaryOps.setdefault(this, key, defaultValue)); }
public PythonTuple popitem() { return(DictionaryOps.popitem(this)); }
public object pop(object key, object defaultValue) { return(DictionaryOps.pop(this, key, defaultValue)); }
public object pop(object key) { return(DictionaryOps.pop(this, key)); }
public bool has_key(object key) { return(DictionaryOps.has_key(this, key)); }
public object get(object key) { return(DictionaryOps.get(this, key)); }