forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuple.cs
More file actions
65 lines (57 loc) · 2.13 KB
/
Copy pathTuple.cs
File metadata and controls
65 lines (57 loc) · 2.13 KB
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
65
using System.Collections.Generic;
namespace LibGit2Sharp.Core.Compat
{
/// <summary>
/// Represents a 2-tuple, or pair.
/// </summary>
/// <typeparam name = "T1">The type of the tuple's first component.</typeparam>
/// <typeparam name = "T2">The type of the tuple's second component.</typeparam>
public class Tuple<T1, T2>
{
private readonly KeyValuePair<T1, T2> kvp;
/// <summary>
/// Initializes a new instance of the <see cref="Tuple{T1,T2}"/> class.
/// </summary>
/// <param name="item1">The value of the tuple's first component.</param>
/// <param name="item2">The value of the tuple's second component.</param>
public Tuple(T1 item1, T2 item2)
{
kvp = new KeyValuePair<T1, T2>(item1, item2);
}
/// <summary>
/// Gets the value of the current <see cref = "Tuple{T1,T2}" /> object's second component.
/// </summary>
public T2 Item2
{
get { return kvp.Value; }
}
/// <summary>
/// Gets the value of the current <see cref = "Tuple{T1,T2}" /> object's first component.
/// </summary>
public T1 Item1
{
get { return kvp.Key; }
}
/// <summary>
/// Returns the hash code for the current <see cref = "Tuple{T1,T2}" /> object.
/// </summary>
/// <returns>A 32-bit signed integer hash code.</returns>
public override int GetHashCode()
{
return kvp.GetHashCode();
}
/// <summary>
/// Returns a value that indicates whether the current <see cref = "Tuple{T1,T2}" /> object is equal to a specified object.
/// </summary>
/// <param name = "obj">The object to compare with this instance.</param>
/// <returns>true if the current instance is equal to the specified object; otherwise, false.</returns>
public override bool Equals(object obj)
{
if (!(obj is Tuple<T1, T2>))
{
return false;
}
return kvp.Equals(((Tuple<T1, T2>)obj).kvp);
}
}
}