PairComparer.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 / PairComparer.cs / 1305376 / PairComparer.cs

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

using System.Collections.Generic; 

namespace System.Linq.Parallel 
{ 
    /// 
    /// PairComparer compares pairs by the first element, and breaks ties by the second 
    /// element.
    /// 
    /// 
    ///  
    internal class PairComparer : IComparer>
    { 
        private IComparer m_comparer1; 
        private IComparer m_comparer2;
 
        public PairComparer(IComparer comparer1, IComparer comparer2)
        {
            m_comparer1 = comparer1;
            m_comparer2 = comparer2; 
        }
 
        public int Compare(Pair x, Pair y) 
        {
            int result1 = m_comparer1.Compare(x.First, y.First); 
            if (result1 != 0)
            {
                return result1;
            } 

            return m_comparer2.Compare(x.Second, y.Second); 
        } 
    }
} 

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

using System.Collections.Generic; 

namespace System.Linq.Parallel 
{ 
    /// 
    /// PairComparer compares pairs by the first element, and breaks ties by the second 
    /// element.
    /// 
    /// 
    ///  
    internal class PairComparer : IComparer>
    { 
        private IComparer m_comparer1; 
        private IComparer m_comparer2;
 
        public PairComparer(IComparer comparer1, IComparer comparer2)
        {
            m_comparer1 = comparer1;
            m_comparer2 = comparer2; 
        }
 
        public int Compare(Pair x, Pair y) 
        {
            int result1 = m_comparer1.Compare(x.First, y.First); 
            if (result1 != 0)
            {
                return result1;
            } 

            return m_comparer2.Compare(x.Second, y.Second); 
        } 
    }
} 

// 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