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> { ...@@ -133,16 +133,19 @@ public class Link implements Comparable<Link> {
@Override @Override
public int compareTo(Link a) { public int compareTo(Link a) {
// compare link based on natural ordering - src id, src port, dst id, dst port // compare link based on natural ordering - src id, src port, dst id, dst port
if (this.getSrc() != a.getSrc()) int srcComp = this.getSrc().compareTo(a.getSrc());
return (int) (this.getSrc().getLong() - a.getSrc().getLong()); if (srcComp != 0)
return srcComp;
if (this.getSrcPort() != a.getSrcPort()) int srcPortComp = this.getSrcPort().compareTo(a.getSrcPort());
return (int) (this.getSrc().getLong() - a.getSrc().getLong()); if (srcPortComp != 0)
return srcPortComp;
int dstComp = this.getDst().compareTo(a.getDst());
if (dstComp != 0)
return dstComp;
if (this.getDst() != a.getDst()) return this.getDstPort().compareTo(a.getDstPort());
return (int) (this.getDst().getLong() - a.getDst().getLong());
return this.getDstPort().getPortNumber() - a.getDstPort().getPortNumber();
} }
} }
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