-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPair.java
More file actions
52 lines (48 loc) · 1.09 KB
/
Pair.java
File metadata and controls
52 lines (48 loc) · 1.09 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
/**
* This utility class stores two items together in a pair.
* It could be used, for instance, to faciliate returning of
* two values in a function.
*
* @author cs2030
* @param <T> the type of the first element
* @param <U> the type of the second element
**/
public class Pair<T, U> {
private final T t;
private final U u;
/**
* Creates a {@code Pair} of items.
*
* @param t first item of the pair
* @param u second item of the pair
**/
public Pair(T t, U u) {
this.t = t;
this.u = u;
}
/**
* Returns the first item of the pair.
*
* @return the first item of the pair
*/
public T t() {
return this.t;
}
/**
* Returns the second item of the pair.
*
* @return the second item of the pair
*/
public U u() {
return this.u;
}
/**
* Returns the string representation of the pair.
*
* @return the string representation of the pair
*/
@Override
public String toString() {
return "Pair[t=" + this.t + ", u=" + this.u + "]";
}
}