diff options
Diffstat (limited to 'src/Chapter5/support/NodeIDComparator.java')
-rw-r--r-- | src/Chapter5/support/NodeIDComparator.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Chapter5/support/NodeIDComparator.java b/src/Chapter5/support/NodeIDComparator.java new file mode 100644 index 0000000..0b41ae7 --- /dev/null +++ b/src/Chapter5/support/NodeIDComparator.java @@ -0,0 +1,32 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package Chapter5.support; + +import java.util.Comparator; + +/** + * + * @author shamanth + */ +public class NodeIDComparator implements Comparator +{ + + public int compare(Object o1, Object o2) { + int id1 = ((NetworkNode) o1).id; + int id2 = ((NetworkNode) o2).id; + if(id1>id2) + { + return 1; + } + else + if(id1<id2) + return -1; + else + return 0; + } + + +} |