-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParentArraySet.java
More file actions
102 lines (80 loc) · 2.18 KB
/
Copy pathParentArraySet.java
File metadata and controls
102 lines (80 loc) · 2.18 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package ToArrayExcel;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.LinkedList;
/**
*
* @author Administrator
*/
public class ParentArraySet {
private int transaction;
private LinkedList<ParentNodeList> aParent;
private boolean isMarked = false;
public ParentArraySet(int transaction){
this.transaction = transaction;
aParent = new LinkedList<ParentNodeList>();
}
public void setMark(boolean b){
this.isMarked = b;
}
public boolean getMark(){
return isMarked;
}
public void add(int source, int target){
ParentNodeList pnl = new ParentNodeList();
pnl.source = source;
pnl.target = target;
aParent.add(pnl);
}
public String NodeMapString(int index){
return String.format("%dto%d", aParent.get(index).source, aParent.get(index).target);
}
public int size(){
return aParent.size();
}
public int getTransaction(){
return this.transaction;
}
public boolean isSameTransaction(int transaction){
if(this.transaction == transaction){
return true;
}
else return false;
}
public boolean isNewTransaction(int transaction){
if(this.transaction < transaction){
return true;
}
return false;
}
public boolean isRouteExist(int source, int target){
int size = aParent.size();
for(int i = 0; i < size; i++){
ParentNodeList pnl = aParent.get(i);
if(pnl.source == source && pnl.target == target)
return true;
}
return false;
}
public boolean isReachedBS(){
if(aParent.get(aParent.size() - 1).target == 0)
return true;
else
return false;
}
public int getSource(int index){
return aParent.get(index).source;
}
public int getTarget(int index){
return aParent.get(index).target;
}
public void changeTransaction(int transaction){
this.transaction = transaction;
}
}
class ParentNodeList{
public int source;
public int target;
}