private void MergeInOrderTraversal(RedBlackTreeSet <T> anotherSet, Action <T> thisHandler, Action <T> anotherHandler, Action <T> equalHandler)
        {
            var thisEnumerator    = GetEnumerator();
            var anotherEnumerator = anotherSet.GetEnumerator();

            var thisEnded    = !thisEnumerator.MoveNext();
            var anotherEnded = !anotherEnumerator.MoveNext();

            while (!thisEnded && !anotherEnded)
            {
                int compareResult = comparer.Compare(thisEnumerator.Current, anotherEnumerator.Current);
                if (compareResult < 0)
                {
                    thisHandler?.Invoke(thisEnumerator.Current);
                    thisEnded = !thisEnumerator.MoveNext();
                }
                else if (compareResult > 0)
                {
                    anotherHandler?.Invoke(anotherEnumerator.Current);
                    anotherEnded = !anotherEnumerator.MoveNext();
                }
                else
                {
                    equalHandler?.Invoke(anotherEnumerator.Current);
                    thisEnded    = !thisEnumerator.MoveNext();
                    anotherEnded = !anotherEnumerator.MoveNext();
                }
            }

            if (!thisEnded)
            {
                do
                {
                    thisHandler?.Invoke(thisEnumerator.Current);
                } while (thisEnumerator.MoveNext());
            }

            if (!anotherEnded)
            {
                do
                {
                    anotherHandler?.Invoke(anotherEnumerator.Current);
                } while (anotherEnumerator.MoveNext());
            }
        }
        public bool IsSubset(RedBlackTreeSet <T> anotherSet)
        {
            if (anotherSet == null)
            {
                throw new ArgumentNullException(nameof(anotherSet));
            }

            if (this.Empty)
            {
                return(true);
            }

            if (this.Count > anotherSet.Count)
            {
                return(false);
            }

            var thisEnumerator    = GetEnumerator();
            var anotherEnumerator = anotherSet.GetEnumerator();

            var thisEnded    = !thisEnumerator.MoveNext();
            var anotherEnded = !anotherEnumerator.MoveNext();

            while (!thisEnded && !anotherEnded)
            {
                int compareResult = comparer.Compare(thisEnumerator.Current, anotherEnumerator.Current);
                if (compareResult < 0)
                {
                    return(false);
                }
                else if (compareResult > 0)
                {
                    anotherEnded = !anotherEnumerator.MoveNext();
                }
                else
                {
                    thisEnded    = !thisEnumerator.MoveNext();
                    anotherEnded = !anotherEnumerator.MoveNext();
                }
            }

            return(thisEnded);
        }