forked from Real-Serious-Games/C-Sharp-Promise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tuple.cs
148 lines (134 loc) · 5.71 KB
/
Tuple.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
namespace RSG
{
/// <summary>
/// Provides static methods for creating tuple objects.
///
/// Tuple implementation for .NET 3.5
/// </summary>
public class Tuple
{
/// <summary>
/// Create a new 2-tuple, or pair.
/// </summary>
/// <typeparam name="T1">The type of the first component of the tuple.</typeparam>
/// <typeparam name="T2">The type of the second component of the tuple.</typeparam>
/// <param name="item1">The value of the first component of the tuple.</param>
/// <param name="item2">The value of the second component of the tuple.</param>
/// <returns>A 2-tuple whose value is (item1, item2)</returns>
public static Tuple<T1, T2> Create<T1, T2>(T1 item1, T2 item2)
{
return new Tuple<T1, T2>(item1, item2);
}
/// <summary>
/// Create a new 3-tuple, or triple.
/// </summary>
/// <typeparam name="T1">The type of the first component of the tuple.</typeparam>
/// <typeparam name="T2">The type of the second component of the tuple.</typeparam>
/// <typeparam name="T3">The type of the third component of the tuple.</typeparam>
/// <param name="item1">The value of the first component of the tuple.</param>
/// <param name="item2">The value of the second component of the tuple.</param>
/// <param name="item3">The value of the third component of the tuple.</param>
/// <returns>A 3-tuple whose value is (item1, item2, item3)</returns>
public static Tuple<T1, T2, T3> Create<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
{
return new Tuple<T1, T2, T3>(item1, item2, item3);
}
/// <summary>
/// Create a new 4-tuple, or quadruple.
/// </summary>
/// <typeparam name="T1">The type of the first component of the tuple.</typeparam>
/// <typeparam name="T2">The type of the second component of the tuple.</typeparam>
/// <typeparam name="T3">The type of the third component of the tuple.</typeparam>
/// <typeparam name="T4">The type of the fourth component of the tuple.</typeparam>
/// <param name="item1">The value of the first component of the tuple.</param>
/// <param name="item2">The value of the second component of the tuple.</param>
/// <param name="item3">The value of the third component of the tuple.</param>
/// <param name="item4">The value of the fourth component of the tuple.</param>
/// <returns>A 3-tuple whose value is (item1, item2, item3, item4)</returns>
public static Tuple<T1, T2, T3, T4> Create<T1, T2, T3, T4>(T1 item1, T2 item2, T3 item3, T4 item4)
{
return new Tuple<T1, T2, T3, T4>(item1, item2, item3, item4);
}
}
/// <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>
{
internal Tuple(T1 item1, T2 item2)
{
Item1 = item1;
Item2 = item2;
}
/// <summary>
/// Gets the value of the current tuple's first component.
/// </summary>
public T1 Item1 { get; private set; }
/// <summary>
/// Gets the value of the current tuple's second component.
/// </summary>
public T2 Item2 { get; private set; }
}
/// <summary>
/// Represents a 3-tuple, or triple.
/// </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>
/// <typeparam name="T3">The type of the tuple's third component.</typeparam>
public class Tuple<T1, T2, T3>
{
internal Tuple(T1 item1, T2 item2, T3 item3)
{
Item1 = item1;
Item2 = item2;
Item3 = item3;
}
/// <summary>
/// Gets the value of the current tuple's first component.
/// </summary>
public T1 Item1 { get; private set; }
/// <summary>
/// Gets the value of the current tuple's second component.
/// </summary>
public T2 Item2 { get; private set; }
/// <summary>
/// Gets the value of the current tuple's third component.
/// </summary>
public T3 Item3 { get; private set; }
}
/// <summary>
/// Represents a 4-tuple, or quadruple.
/// </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>
/// <typeparam name="T3">The type of the tuple's third component.</typeparam>
/// <typeparam name="T4">The type of the tuple's fourth component.</typeparam>
public class Tuple<T1, T2, T3, T4>
{
internal Tuple(T1 item1, T2 item2, T3 item3, T4 item4)
{
Item1 = item1;
Item2 = item2;
Item3 = item3;
Item4 = item4;
}
/// <summary>
/// Gets the value of the current tuple's first component.
/// </summary>
public T1 Item1 { get; private set; }
/// <summary>
/// Gets the value of the current tuple's second component.
/// </summary>
public T2 Item2 { get; private set; }
/// <summary>
/// Gets the value of the current tuple's third component.
/// </summary>
public T3 Item3 { get; private set; }
/// <summary>
/// Gets the value of the current tuple's fourth component.
/// </summary>
public T4 Item4 { get; private set; }
}
}