peersim.vector
Class SingleValueComparator

java.lang.Object
  extended by peersim.vector.SingleValueComparator
All Implemented Interfaces:
java.util.Comparator

public class SingleValueComparator
extends java.lang.Object
implements java.util.Comparator

This comparator class compares two node objects based on the value maintained by one of its protocols. The protocol must implement the SingleValue interface; its identifier has to be specified when a new comparator is built.


Constructor Summary
SingleValueComparator(int pid)
          Builds a new comparator that compares the double values maintained by protocol identified by pid.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares the values of two protocols.
 
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
 

Constructor Detail

SingleValueComparator

public SingleValueComparator(int pid)
Builds a new comparator that compares the double values maintained by protocol identified by pid.

Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares the values of two protocols. The parameters must have dynamic type Node. The protocol pid is accessed on both nodes. These protocols have to implement the SingleValue interface. The values held by these protocol instances are then compared.

Specified by:
compare in interface java.util.Comparator