Package ptolemy.domains.dde.kernel
Class ReceiverComparator
- java.lang.Object
-
- ptolemy.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$
- Author:
- John S. Davis II
- See Also:
DDEThread
- Pt.AcceptedRating:
- Green (kienhuis)
- Pt.ProposedRating:
- Green (davisj)
-
-
Constructor Summary
Constructors Constructor Description ReceiverComparator(TimeKeeper timeKeeper)
Construct a ReceiverComparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(java.lang.Object object1, java.lang.Object object2)
Compare two receivers according to ReceiverTime and priority.
-
-
-
Constructor Detail
-
ReceiverComparator
public ReceiverComparator(TimeKeeper timeKeeper)
Construct a ReceiverComparator.- Parameters:
timeKeeper
- The time keeper that controls the receivers.
-
-
Method Detail
-
compare
public int compare(java.lang.Object object1, java.lang.Object object2)
Compare two receivers according to ReceiverTime and priority.- Specified by:
compare
in interfacejava.util.Comparator
- Parameters:
object1
- The first object to be compared.object2
- The second object to be compared.- Returns:
- +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.
- Throws:
java.lang.ClassCastException
- If object1 and obj2 are not instances of PrioritizedTimedQueue.
-
-