-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPair.java
More file actions
39 lines (34 loc) · 738 Bytes
/
Pair.java
File metadata and controls
39 lines (34 loc) · 738 Bytes
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
public class Pair<T1,T2>
{
private T1 first;
private T2 second;
public Pair(T1 aFirst, T2 aSecond)
{
first = aFirst;
second = aSecond;
}
/* Gets the first element of this pair.
* @return the first element of this pair.
*/
public T1 fst()
{
return first;
}
/* Gets the second element of this pair.
* @return the second element of this pair.
*/
public T2 snd()
{
return second;
}
/* Generates a string representing this pair. Note that
* the String representing the pair (x,y) is "(x,y)". There
* is no whitespace unless x or y or both contain whitespace
* themselves.
* @return a string representing this pair.
*/
public String toString()
{
return "(" + first + "," + second + ")";
}
}