-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPair.java
More file actions
35 lines (33 loc) · 771 Bytes
/
Pair.java
File metadata and controls
35 lines (33 loc) · 771 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
package M;
public class Pair<L,R> implements Comparable<Pair>
{
public L l; // attribute l ---> left
public R r; // attribute r ---> right
public Pair(L l, R r)
{
this.l = l;
this.r = r;
}
public L getL()
{
return l;
}
public R getR()
{
return r;
}
public void setL(L l)
{
this.l = l;
}
public void setR(R r)
{
this.r = r;
}
@Override
public int compareTo(Pair o) {
/* when we compare between two objects from this class this method specifies the criteria */
return (int)l < (int)o.l ? -1 : (int)l > (int)o.l ? 1 : 0;
/* returns -1 if the sent object is bigger or one if I'm bigger than the sent or zero if equal */
}
}