e8e81bd325ad2086c18db85b3ae76e5776cf884a
[mono.git] / mcs / class / referencesource / System.Core / System / Linq / Parallel / Utils / ReverseComparer.cs
1 // ==++==
2 //
3 //   Copyright (c) Microsoft Corporation.  All rights reserved.
4 // 
5 // ==--==
6 // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
7 //
8 // ReverseComparer.cs
9 //
10 // <OWNER>Microsoft</OWNER>
11 //
12 // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
13
14 using System.Collections.Generic;
15
16 namespace System.Linq.Parallel
17 {
18     /// <summary>
19     /// Comparer that wraps another comparer, and flips the result of each comparison to the
20     /// opposite answer.
21     /// </summary>
22     /// <typeparam name="T"></typeparam>
23     internal class ReverseComparer<T> : IComparer<T>
24     {
25         private IComparer<T> m_comparer;
26
27         internal ReverseComparer(IComparer<T> comparer)
28         {
29             m_comparer = comparer;
30         }
31
32         public int Compare(T x, T y)
33         {
34             return -m_comparer.Compare(x, y);
35         }
36     }
37 }