Skip to content
Snippets Groups Projects
Commit 3ee027bb authored by Ryan Izard's avatar Ryan Izard
Browse files

Merge pull request #588 from RicardoFonseca/patch-1

Fixed srcPort bug in compareTo()
parents cde75973 232ec109
No related branches found
No related tags found
No related merge requests found
......@@ -133,16 +133,19 @@ public class Link implements Comparable<Link> {
@Override
public int compareTo(Link a) {
// compare link based on natural ordering - src id, src port, dst id, dst port
if (this.getSrc() != a.getSrc())
return (int) (this.getSrc().getLong() - a.getSrc().getLong());
int srcComp = this.getSrc().compareTo(a.getSrc());
if (srcComp != 0)
return srcComp;
if (this.getSrcPort() != a.getSrcPort())
return (int) (this.getSrc().getLong() - a.getSrc().getLong());
int srcPortComp = this.getSrcPort().compareTo(a.getSrcPort());
if (srcPortComp != 0)
return srcPortComp;
int dstComp = this.getDst().compareTo(a.getDst());
if (dstComp != 0)
return dstComp;
if (this.getDst() != a.getDst())
return (int) (this.getDst().getLong() - a.getDst().getLong());
return this.getDstPort().getPortNumber() - a.getDstPort().getPortNumber();
return this.getDstPort().compareTo(a.getDstPort());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment