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: ReceiverComparator.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- John S. Davis II
- See Also:
DDEThread
- Accepted Rating:
- Proposed Rating:
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 |
_timeKeeper
private TimeKeeper _timeKeeper
ReceiverComparator
public ReceiverComparator(TimeKeeper timeKeeper)
- Construct a ReceiverComparator.
- Parameters:
timeKeeper
- The time keeper that controls the receivers.
compare
public int compare(java.lang.Object object1,
java.lang.Object object2)
- Compare two receivers according to ReceiverTime and priority.
- Specified by:
compare
in interface java.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.