-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExchange.java
More file actions
84 lines (69 loc) · 1.55 KB
/
Exchange.java
File metadata and controls
84 lines (69 loc) · 1.55 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
public class Exchange {
int idd;
Exchange parent;
ExchangeList children;
MobilePhoneSet phoneset;
public Exchange(int d)
{
idd=d;
children=new ExchangeList();
phoneset=new MobilePhoneSet();
}
public Exchange parent()
{
return parent;
}
public int numchild()
{
return children.getCount();
}
public Exchange child(int i)
{
node temp=children.head;
int c=this.children.getCount();
if(i>=c)
return null;
for(int n=(c-1);n>(i);n--){
temp=temp.next;
}
return temp.data;
}
public boolean isRoot()
{
if(this.parent==null)
return true;
else
return false;
}
public int depth()
{
int f=0;
Exchange g=this;
while(!g.isRoot())
{
f++;
g=g.parent;
}
return f;
}
public MobilePhoneSet residentSet()
{
return phoneset;
}
public RoutingMapTree subtree(int i)
{
node temp=children.head;
int c=this.children.getCount();
for(int n=(c-1);n<(c-i);n--) {
temp = temp.next;
}
RoutingMapTree newtree=new RoutingMapTree();
newtree.root=temp.data;
return newtree;
}
public void addchild(Exchange b)
{
children.push(b);
b.parent=this;
}
}