WrapperEqualityComparer.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / Utils / WrapperEqualityComparer.cs / 1305376 / WrapperEqualityComparer.cs

                            // ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
// 
// WrapperEqualityComparer.cs 
//
// [....] 
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

using System.Collections.Generic; 
using System.Diagnostics.Contracts;
 
namespace System.Linq.Parallel 
{
    ///  
    /// Compares two wrapped structs of the same underlying type for equality.  Simply
    /// wraps the actual comparer for the type being wrapped.
    /// 
    ///  
    internal struct WrapperEqualityComparer : IEqualityComparer>
    { 
        private IEqualityComparer m_comparer; 

        internal WrapperEqualityComparer(IEqualityComparer comparer) 
        {
            if (comparer == null)
            {
                m_comparer = EqualityComparer.Default; 
            }
            else 
            { 
                m_comparer = comparer;
            } 
        }

        public bool Equals(Wrapper x, Wrapper y)
        { 
            Contract.Assert(m_comparer != null);
            return m_comparer.Equals(x.Value, y.Value); 
        } 

        public int GetHashCode(Wrapper x) 
        {
            Contract.Assert(m_comparer != null);
            return m_comparer.GetHashCode(x.Value);
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
// 
// WrapperEqualityComparer.cs 
//
// [....] 
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

using System.Collections.Generic; 
using System.Diagnostics.Contracts;
 
namespace System.Linq.Parallel 
{
    ///  
    /// Compares two wrapped structs of the same underlying type for equality.  Simply
    /// wraps the actual comparer for the type being wrapped.
    /// 
    ///  
    internal struct WrapperEqualityComparer : IEqualityComparer>
    { 
        private IEqualityComparer m_comparer; 

        internal WrapperEqualityComparer(IEqualityComparer comparer) 
        {
            if (comparer == null)
            {
                m_comparer = EqualityComparer.Default; 
            }
            else 
            { 
                m_comparer = comparer;
            } 
        }

        public bool Equals(Wrapper x, Wrapper y)
        { 
            Contract.Assert(m_comparer != null);
            return m_comparer.Equals(x.Value, y.Value); 
        } 

        public int GetHashCode(Wrapper x) 
        {
            Contract.Assert(m_comparer != null);
            return m_comparer.GetHashCode(x.Value);
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK