-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tuple.java
executable file
·56 lines (45 loc) · 1.11 KB
/
Tuple.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
/*
* Tuple.java
*
* Created on November 29, 2007, 2:54 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author shuralydm
*/
public class Tuple<E> {
private E first;
private E second;
/** Creates a new instance of Tuple */
public Tuple(E first, E second) {
this.first = first;
this.second = second;
}
public E getFirst() {
return this.first;
}
public E getSecond() {
return this.second;
}
public void setFirst(E first) {
this.first = first;
}
public void setSecond(E second) {
this.second = second;
}
public boolean doesOverlap(Tuple<Integer> other)
{
return !((other.getSecond() <= (Integer)getFirst()) || ((Integer)getSecond() <= other.getFirst()));
}
@Override
public String toString() {
return "(" + getFirst() + ", " + getSecond() + ")";
}
public static Tuple<Integer> valueOfInteger(String tupleString) {
String[] tuple = tupleString.split("\\D");
return new Tuple<Integer>(Integer.valueOf(tuple[1]), Integer.valueOf(tuple[3]));
}
}