public int __cmp__(object other) { if (!(other is ClosureCell cc)) { throw PythonOps.TypeError("cell.__cmp__(x,y) expected cell, got {0}", PythonTypeOps.GetName(other)); } return(PythonOps.Compare(Value, cc.Value)); }
public int __cmp__([NotNull] PythonBuffer other) { if (Object.ReferenceEquals(this, other)) { return(0); } return(PythonOps.Compare(ToString(), other.ToString())); }
public static void unregister(CodeContext context, object func) { var functions = context.LanguageContext.GetModuleState(_registry_key) as List <FunctionDescriptor>; if (functions != null) { lock (functions) { functions.RemoveAll(x => PythonOps.Compare(context, x.Func, func) == 0); } } }
public int __cmp__(CodeContext /*!*/ context, [NotNull] BuiltinFunction /*!*/ other) { if (other == this) { return(0); } if (!IsUnbound && !other.IsUnbound) { int result = PythonOps.Compare(__self__, other.__self__); if (result != 0) { return(result); } if (_data == other._data) { return(0); } } int res = String.CompareOrdinal(__name__, other.__name__); if (res != 0) { return(res); } res = String.CompareOrdinal(Get__module__(context), other.Get__module__(context)); if (res != 0) { return(res); } long lres = IdDispenser.GetId(this) - IdDispenser.GetId(other); return(lres > 0 ? 1 : -1); }
private int CompareToWorker(deque otherDeque, IComparer comparer) { Assert.NotNull(otherDeque); if (otherDeque._itemCnt == 0 && _itemCnt == 0) { // comparing two empty deques return(0); } if (CompareUtil.Check(this)) { return(0); } CompareUtil.Push(this); try { int otherIndex = otherDeque._head, ourIndex = _head; for (; ;) { int result; if (comparer == null) { result = PythonOps.Compare(_data[ourIndex], otherDeque._data[otherIndex]); } else { result = comparer.Compare(_data[ourIndex], otherDeque._data[otherIndex]); } if (result != 0) { return(result); } // advance both indexes otherIndex++; if (otherIndex == otherDeque._data.Length) { otherIndex = 0; } if (otherIndex == otherDeque._tail) { break; } ourIndex++; if (ourIndex == _data.Length) { ourIndex = 0; } if (ourIndex == _tail) { break; } } // all items are equal, but # of items may be different. if (otherDeque._itemCnt == _itemCnt) { // same # of items, all items are equal return(0); } return(_itemCnt > otherDeque._itemCnt ? 1 : -1); } finally { CompareUtil.Pop(this); } }