ptolemy.domains.dde.kernel
Class ReceiverComparator

java.lang.Object
  extended byptolemy.domains.dde.kernel.ReceiverComparator
All Implemented Interfaces:
java.util.Comparator

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

A ReceiverComparator is used to sort receivers controlled by a time keeper. Receivers are sorted according to ReceiverTime and priority using the compare() method. First receivers are sorted according to ReceiverTime. ReceiverTimes are partitioned into three categories: nonnegative times, PrioritizedTimedQueue.IGNORE times and PrioritizedTimedQueue.INACTIVE times. Nonnegative times precede IGNORE times precede INACTIVE times. Within the nonnegative time category, smaller times precede larger times. The IGNORE and INACTIVE categories each consist of a single value so within these categories comparison results in equality.

If it is determined that two receivers are equivalent according to ReceiverTime, then comparison is made according to the receiver priority. A larger receiver priority will precede a smaller receiver priority. If it is determined that two receivers are equivalent according to ReceiverTime and priority, then the compare() method returns 0.

Since:
Ptolemy II 2.0
Version:
$Id: ReceiverComparator.java,v 1.11 2004/04/13 03:28:40 cxh Exp $
Author:
John S. Davis II
See Also:
DDEThread
Accepted Rating:
Green (kienhuis)
Proposed Rating:
Green (davisj)

Constructor Summary
ReceiverComparator(TimeKeeper cntlr)
           
 
Method Summary
 int compare(java.lang.Object object1, java.lang.Object object2)
          Compare two receivers according to ReceiverTime and priority.
 
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

ReceiverComparator

public ReceiverComparator(TimeKeeper cntlr)
Method Detail

compare

public int compare(java.lang.Object object1,
                   java.lang.Object object2)
Compare two receivers according to ReceiverTime and priority. Return +1, -1 or 0 if the first receiver argument will be ordered before, after or equivalent to the second receiver argument, respectively. Base the ordering first on the ReceiverTimes. If the ReceiverTimes are equal, then base the ordering on the receiver priority.

Specified by:
compare in interface java.util.Comparator
Throws:
java.lang.ClassCastException - If object1 and obj2 are not instances of PrioritizedTimedQueue.