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