- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouterPacket.java
More file actions
Latest commit
executable file
·29 lines (23 loc) · 830 Bytes
/
Copy pathRouterPacket.java
File metadata and controls
executable file
·29 lines (23 loc) · 830 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
publicclassRouterPacketimplementsCloneable {
intsourceid; /* id of sending router sending this pkt */
intdestid; /* id of router to which pkt being sent
(must be an immediate neighbor) */
int[] mincost = newint[RouterSimulator.NUM_NODES]; /* min cost to node 0 ... 3 */
RouterPacket (intsourceID, intdestID, int[] mincosts){
this.sourceid = sourceID;
this.destid = destID;
System.arraycopy(mincosts, 0, this.mincost, 0, RouterSimulator.NUM_NODES);
}
publicObjectclone(){
try {
RouterPacketnewPkt = (RouterPacket) super.clone();
newPkt.mincost = (int[]) newPkt.mincost.clone();
returnnewPkt;
}
catch(CloneNotSupportedExceptione){
System.err.println(e);
System.exit(1);
}
returnnull;
}
}