forked from LiHypnos/Grafos-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPair.java
36 lines (31 loc) · 918 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
import java.util.Objects;
public class Pair<K, V, D> {
K key; //representa o vertice de origem
V value; //o valor da aresta
D destiny; //o vertice de destino
Pair(K key, V value, D destiny) {
this.key = key;
this.value = value;
this.destiny = destiny;
}
K getOrigin() {
return key;
}
D getDestiny() {
return destiny;
}
V getValue() {
return value;
}
@Override
public boolean equals(Object obj) { //metodo que perimite a comparação do tipo pair
if (this == obj) return true;
if (!(obj instanceof Pair)) return false;
Pair<?, ?, ?> pair = (Pair<?, ?, ?>) obj;
return Objects.equals(key, pair.key) && Objects.equals(value, pair.value) && Objects.equals(destiny, pair.destiny);
}
@Override
public int hashCode() {
return Objects.hash(key, value, destiny);
}
}