Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
AnonymousComparer.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 
6 namespace SiliconStudio.Presentation.Core
7 {
8  /// <summary>
9  /// This class allows implementation of <see cref="IComparer{T}"/> using an anonymous function.
10  /// </summary>
11  /// <typeparam name="T">The type of object this comparer can compare.</typeparam>
12  public class AnonymousComparer<T> : IComparer<T>
13  {
14  private readonly Func<T, T, int> compare;
15 
16  /// <summary>
17  /// Initializes a new instance of the <see cref="AnonymousComparer{T}"/> class.
18  /// </summary>
19  /// <param name="compare">The comparison function to use for this comparer.</param>
20  public AnonymousComparer(Func<T, T, int> compare)
21  {
22  if (compare == null) throw new ArgumentNullException("compare");
23  this.compare = compare;
24  }
25 
26  /// <inheritdoc/>
27  public int Compare(T x, T y)
28  {
29  return compare(x, y);
30  }
31  }
32 }
AnonymousComparer(Func< T, T, int > compare)
Initializes a new instance of the AnonymousComparer{T} class.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
Definition: DirectXTexP.h:191