Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EqualityComparer.cs
Go to the documentation of this file.
3
5
7[TypeDependency("System.Collections.Generic.ObjectEqualityComparer`1")]
8[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
10{
16
17
18 public abstract bool Equals(T? x, T? y);
19
20 public abstract int GetHashCode([DisallowNull] T obj);
21
23 {
24 if (obj == null)
25 {
26 return 0;
27 }
28 if (obj is T)
29 {
30 return GetHashCode((T)obj);
31 }
32 ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidArgumentForComparison);
33 return 0;
34 }
35
36 bool IEqualityComparer.Equals(object x, object y)
37 {
38 if (x == y)
39 {
40 return true;
41 }
42 if (x == null || y == null)
43 {
44 return false;
45 }
46 if (x is T && y is T)
47 {
48 return Equals((T)x, (T)y);
49 }
50 ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidArgumentForComparison);
51 return false;
52 }
53
54 internal virtual int IndexOf(T[] array, T value, int startIndex, int count)
55 {
56 int num = startIndex + count;
57 for (int i = startIndex; i < num; i++)
58 {
59 if (Equals(array[i], value))
60 {
61 return i;
62 }
63 }
64 return -1;
65 }
66
67 internal virtual int LastIndexOf(T[] array, T value, int startIndex, int count)
68 {
69 int num = startIndex - count + 1;
70 for (int num2 = startIndex; num2 >= num; num2--)
71 {
72 if (Equals(array[num2], value))
73 {
74 return num2;
75 }
76 }
77 return -1;
78 }
79}
static object CreateDefaultEqualityComparer(Type type)
int GetHashCode([DisallowNull] T obj)
virtual int IndexOf(T[] array, T value, int startIndex, int count)
virtual int LastIndexOf(T[] array, T value, int startIndex, int count)
static void ThrowArgumentException(ExceptionResource resource)