/
HandleComparer.cs
64 lines (54 loc) · 1.77 KB
/
HandleComparer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
namespace System.Reflection.Metadata
{
public sealed class HandleComparer : IEqualityComparer<Handle>, IComparer<Handle>, IEqualityComparer<EntityHandle>, IComparer<EntityHandle>
{
private static readonly HandleComparer s_default = new HandleComparer();
private HandleComparer()
{
}
public static HandleComparer Default
{
get { return s_default; }
}
public bool Equals(Handle x, Handle y)
{
return x.Equals(y);
}
public bool Equals(EntityHandle x, EntityHandle y)
{
return x.Equals(y);
}
public int GetHashCode(Handle obj)
{
return obj.GetHashCode();
}
public int GetHashCode(EntityHandle obj)
{
return obj.GetHashCode();
}
/// <summary>
/// Compares two handles.
/// </summary>
/// <remarks>
/// The order of handles that differ in kind and are not <see cref="EntityHandle"/> is undefined.
/// Returns 0 if and only if <see cref="Equals(Handle, Handle)"/> returns true.
/// </remarks>
public int Compare(Handle x, Handle y)
{
return Handle.Compare(x, y);
}
/// <summary>
/// Compares two entity handles.
/// </summary>
/// <remarks>
/// Returns 0 if and only if <see cref="Equals(EntityHandle, EntityHandle)"/> returns true.
/// </remarks>
public int Compare(EntityHandle x, EntityHandle y)
{
return EntityHandle.Compare(x, y);
}
}
}