/// <summary>
        /// Builds a new <see cref="Set{T}"/> containing only items found exclusivly in one of both specified sets.
        /// </summary>
        /// <param name="set1">The first set used to calculate the result.</param>
        /// <param name="set2">The second set used to calculate the result.</param>
        /// <returns>Returns a new <see cref="Set{T}"/> containing the result.</returns>
        public static IndexedSet <T> Xor(IndexedSet <T> set1, IndexedSet <T> set2)
        {
            if (set1 == null)
            {
                throw new ArgumentNullException("set1");
            }

            if (set2 == null)
            {
                throw new ArgumentNullException("set2");
            }

            if (set1.Count < set2.Count)
            {
                return(Xor(set2, set1));
            }

            LinkedList <T> newSet2 = new LinkedList <T>(set2);
            IndexedSet <T> result  = new IndexedSet <T>();

            foreach (T setItem in set1)
            {
                if (!set2.Contains(setItem))
                {
                    result.Add(setItem);
                }
                else
                {
                    newSet2.Remove(setItem);
                }
            }
            result.AddRange(newSet2);
            return(result);
        }
        /// <summary>
        /// Builds the intersection of two specified <see cref="Set{T}"/>s.
        /// </summary>
        /// <param name="set1">The first set used to calculate the result.</param>
        /// <param name="set2">The second set used to calculate the result.</param>
        /// <returns>Returns a new <see cref="Set{T}"/> containing the result.</returns>
        public static IndexedSet <T> BitwiseAnd(IndexedSet <T> set1, IndexedSet <T> set2)
        {
            if (set1 == null)
            {
                throw new ArgumentNullException("set1");
            }

            if (set2 == null)
            {
                throw new ArgumentNullException("set2");
            }

            if (set1.Count < set2.Count)
            {
                return(BitwiseAnd(set2, set1));
            }

            IndexedSet <T> result = new IndexedSet <T>();

            foreach (T itemsItem in set1)
            {
                if (set2.Contains(itemsItem))
                {
                    result.Add(itemsItem);
                }
            }
            return(result);
        }
        /// <summary>
        /// Subtracts the specified <see cref="Set{T}"/> from this one and returns a new <see cref="Set{T}"/> containing the result.
        /// </summary>
        /// <param name="set1">The first set used to calculate the result.</param>
        /// <param name="set2">The second set used to calculate the result.</param>
        /// <returns>Returns a new <see cref="Set{T}"/> containing the result.</returns>
        public static IndexedSet <T> Subtract(IndexedSet <T> set1, IndexedSet <T> set2)
        {
            if (set1 == null)
            {
                throw new ArgumentNullException("set1");
            }

            if (set2 == null)
            {
                throw new ArgumentNullException("set2");
            }

            IndexedSet <T> result = new IndexedSet <T>();

            foreach (T setItem in set1)
            {
                if (!set2.Contains(setItem))
                {
                    result.Add(setItem);
                }
            }
            return(result);
        }