-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathPair.java
62 lines (55 loc) · 905 Bytes
/
Pair.java
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
/**
* Data-Structures-In-Java
* Pair.java
*/
package com.deepak.data.structures.Arrays;
/**
* Pair class
*
* @author Deepak
*
* @param <L>
* @param <R>
*/
public class Pair<L, R> {
/* Since pair is immutable, both L and R has to be final */
public final L left;
public final R right;
/**
* Constructor
*
* @param left
* @param right
*/
public Pair(final L left, final R right) {
super();
this.left = left;
this.right = right;
}
/**
* Method to create a new Pair
*
* @param left
* @param right
* @return {@link Pair<L, R>}
*/
public static <L, R> Pair<L, R> of(final L left, final R right) {
return new Pair<>(left, right);
}
/**
* Method to get Left object
*
* @return {@link L}
*/
public L getLeft() {
return left;
}
/**
* Method to get Right Object
*
* @return {@link R}
*/
public R getRight() {
return right;
}
}