Пример #1
0
        bool IStructuralEquatable.Equals(object other, IEqualityComparer /*!*/ comparer)
        {
            SetStorage items;

            return(SetStorage.GetItemsIfSet(other, out items) &&
                   SetStorage.Equals(_items, items, comparer));
        }
Пример #2
0
        public bool __ne__(object other)
        {
            SetStorage items;

            return(!SetStorage.GetItemsIfSet(other, out items) ||
                   _items.Count != items.Count ||
                   !_items.IsSubset(items));
        }
Пример #3
0
        // 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));
        }
Пример #4
0
 public object __ne__(object other)
 {
     if (SetStorage.GetItemsIfSet(other, out SetStorage items))
     {
         return(_items.Count != items.Count || !_items.IsSubset(items));
     }
     return(NotImplementedType.Value);
 }
Пример #5
0
        public static object operator <=(SetCollection self, object other)
        {
            if (SetStorage.GetItemsIfSet(other, out SetStorage items))
            {
                return(self._items.IsSubset(items));
            }

            return(NotImplementedType.Value);
        }
Пример #6
0
        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");
        }