bool IStructuralEquatable.Equals(object other, IEqualityComparer /*!*/ comparer) { SetStorage items; return(SetStorage.GetItemsIfSet(other, out items) && SetStorage.Equals(_items, items, comparer)); }
public bool __ne__(object other) { SetStorage items; return(!SetStorage.GetItemsIfSet(other, out items) || _items.Count != items.Count || !_items.IsSubset(items)); }
// default conversion of protocol methods only allows our specific type for equality, // but sets can do __eq__ / __ne__ against any type. This is why we define a separate // __eq__ / __ne__ here. public bool __eq__(object other) { SetStorage items; return(SetStorage.GetItemsIfSet(other, out items) && _items.Count == items.Count && _items.IsSubset(items)); }
public object __ne__(object other) { if (SetStorage.GetItemsIfSet(other, out SetStorage items)) { return(_items.Count != items.Count || !_items.IsSubset(items)); } return(NotImplementedType.Value); }
public static object operator <=(SetCollection self, object other) { if (SetStorage.GetItemsIfSet(other, out SetStorage items)) { return(self._items.IsSubset(items)); } return(NotImplementedType.Value); }
public static bool operator <=(SetCollection self, object other) { SetStorage items; if (SetStorage.GetItemsIfSet(other, out items)) { return(self._items.IsSubset(items)); } throw PythonOps.TypeError("can only compare to a set"); }