Skip to content
Snippets Groups Projects
Commit 232ec109 authored by RicardoFonseca's avatar RicardoFonseca
Browse files

Better fix than previous commit

Better to rely on the compareTo() method of DatapathId and OFPort.
parent 36908921
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.getSrcPort().getLong() - a.getSrcPort().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