public bool IsProperSubsetOf(RedisSet <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            return(Count < other.Count && IsSubsetOf(other));
        }
        public void ExceptWith(RedisSet <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            SetCombineAndStore(SetOperation.Difference, other);
        }
        public void IntersectWith(RedisSet <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            SetCombineAndStore(SetOperation.Intersect, other);
        }
        public bool SetEquals(RedisSet <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            return(IsSubsetOf(other) && IsSupersetOf(other));
        }
        public bool Overlaps(RedisSet <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            return(SetCombine(SetOperation.Intersect, other).Any());
        }
        public bool IsSupersetOf(RedisSet <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            return(!other.SetCombine(SetOperation.Difference, this).Any());
        }
        private void SetCombineAndStore(SetOperation operation, IEnumerable <T> other)
        {
            var redisTempSet = new RedisSet <T>(_db, Guid.NewGuid().ToString());

            try
            {
                redisTempSet.Add(other);
                SetCombineAndStore(operation, redisTempSet);
            }
            finally
            {
                redisTempSet.Clear();
            }
        }
        public void SymmetricExceptWith(IEnumerable <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            var otherSet = new RedisSet <T>(_db, Guid.NewGuid().ToString());

            try
            {
                otherSet.Add(other);
                SymmetricExceptWith(otherSet);
            }
            finally
            {
                otherSet.Clear();
            }
        }
        public void SymmetricExceptWith(RedisSet <T> other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }

            var intersectedSet = new RedisSet <T>(_db, Guid.NewGuid().ToString());

            try
            {
                SetCombineAndStore(SetOperation.Intersect, intersectedSet, this, other);
                SetCombineAndStore(SetOperation.Union, other);
                SetCombineAndStore(SetOperation.Difference, intersectedSet);
            }
            finally
            {
                intersectedSet.Clear();
            }
        }
 private RedisValue[] SetCombine(SetOperation operation, RedisSet <T> other)
 {
     return(_db.SetCombine(operation, _redisKey, other._redisKey));
 }
 private void SetCombineAndStore(SetOperation operation, RedisSet <T> destination, RedisSet <T> first, RedisSet <T> second)
 {
     _db.SetCombineAndStore(operation, destination._redisKey, first._redisKey, second._redisKey);
 }
 private void SetCombineAndStore(SetOperation operation, RedisSet <T> other)
 {
     SetCombineAndStore(operation, this, this, other);
 }