Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HashSetEqualityComparer.cs
Go to the documentation of this file.
1
using
System.Diagnostics.CodeAnalysis
;
2
3
namespace
System.Collections.Generic
;
4
5
internal
sealed
class
HashSetEqualityComparer
<T> :
IEqualityComparer
<HashSet<T>>
6
{
7
public
bool
Equals
(
HashSet<T>
x,
HashSet<T>
y)
8
{
9
if
(x == y)
10
{
11
return
true
;
12
}
13
if
(x ==
null
|| y ==
null
)
14
{
15
return
false
;
16
}
17
EqualityComparer<T>
@
default
=
EqualityComparer<T>
.Default;
18
if
(
HashSet<T>
.EqualityComparersAreEqual(x, y))
19
{
20
if
(x.
Count
== y.
Count
)
21
{
22
return
y.IsSubsetOfHashSetWithSameComparer(x);
23
}
24
return
false
;
25
}
26
foreach
(T
item
in
y)
27
{
28
bool
flag =
false
;
29
foreach
(T
item2
in
x)
30
{
31
if
(@
default
.
Equals
(
item
,
item2
))
32
{
33
flag =
true
;
34
break
;
35
}
36
}
37
if
(!flag)
38
{
39
return
false
;
40
}
41
}
42
return
true
;
43
}
44
45
public
int
GetHashCode
(
HashSet<T>
obj
)
46
{
47
int
num = 0;
48
if
(
obj
!=
null
)
49
{
50
foreach
(T
item
in
obj
)
51
{
52
if
(
item
!=
null
)
53
{
54
num ^=
item
.GetHashCode();
55
}
56
}
57
}
58
return
num;
59
}
60
61
public
override
bool
Equals
([
NotNullWhen
(
true
)]
object
obj
)
62
{
63
return
obj
is
HashSetEqualityComparer<T>
;
64
}
65
66
public
override
int
GetHashCode
()
67
{
68
return
EqualityComparer<T>
.Default.GetHashCode();
69
}
70
}
System.Collections.Generic.Dictionary.Count
int Count
Definition
Dictionary.cs:682
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Collections.Generic.HashSetEqualityComparer.GetHashCode
int GetHashCode(HashSet< T > obj)
Definition
HashSetEqualityComparer.cs:45
System.Collections.Generic.HashSetEqualityComparer.Equals
bool Equals(HashSet< T > x, HashSet< T > y)
Definition
HashSetEqualityComparer.cs:7
System.Collections.Generic.HashSetEqualityComparer.GetHashCode
override int GetHashCode()
Definition
HashSetEqualityComparer.cs:66
System.Collections.Generic.HashSetEqualityComparer.Equals
override bool Equals([NotNullWhen(true)] object obj)
Definition
HashSetEqualityComparer.cs:61
System.Collections.Generic.HashSetEqualityComparer
Definition
HashSetEqualityComparer.cs:6
System.Collections.Generic.IEqualityComparer
Definition
IEqualityComparer.cs:6
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Diagnostics.CodeAnalysis
Definition
AllowNullAttribute.cs:1
System.ExceptionArgument.item
@ item
System.ExceptionArgument.obj
@ obj
source
System.Private.CoreLib
System.Collections.Generic
HashSetEqualityComparer.cs
Generated by
1.10.0