peersim.vector
Class VectorComparator
java.lang.Object
peersim.vector.VectorComparator
- All Implemented Interfaces:
- java.util.Comparator
public class VectorComparator
- extends java.lang.Object
- implements java.util.Comparator
This class provides a generic implementation of the
java.lang.Comparator interface specialized
for Node
objects. Nodes are compared based
on one of their protocols, on which a configurable
method is invoked. Both the protocol id and the
method are specified in the constructor.
This comparator can be used, for example, to sort
an array of nodes based on method getValue
associated to the protocol pid
:
Comparator c = new VectorComparator(pid, "getValue");
Array.sort(Node[] array, c);
Note that differently from other classes in this package,
VectorComparator is declared programmatically in the code
and not in the configuration file. It is included in this
package because it shares the same philosophy of the other
classes.
Method Summary |
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
VectorComparator
public VectorComparator(int pid,
java.lang.String methodName)
compare
public int compare(java.lang.Object o1,
java.lang.Object o2)
- Specified by:
compare
in interface java.util.Comparator