ptolemy.domains.tm.kernel
Class TMEventComparator
java.lang.Object
ptolemy.domains.tm.kernel.TMEventComparator
- All Implemented Interfaces:
- java.util.Comparator, CQComparator
public class TMEventComparator
- extends java.lang.Object
- implements CQComparator
A comparator for TM events. This class extends CQComparator so that
it can be used by CalendarQueue. This class ignores all the configuration
parameters in CQComparator. Only the default parameters are used.
- Since:
- Ptolemy II 2.0
- Version:
- $Id: TMEventComparator.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Jie Liu
- Accepted Rating:
- Proposed Rating:
Method Summary |
int |
compare(java.lang.Object object1,
java.lang.Object object2)
Compare the two argument for order. |
long |
getVirtualBinNumber(java.lang.Object event)
Given an event, return the virtual index of
the bin that should contain the event. |
void |
setBinWidth(java.lang.Object[] entryArray)
Do nothing. |
void |
setZeroReference(java.lang.Object zeroReference)
Do nothing. |
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 |
TMEventComparator
public TMEventComparator()
compare
public final int compare(java.lang.Object object1,
java.lang.Object object2)
- Compare the two argument for order. Return -1, 0, or 1
if the first argument is less than,
equal to, or greater than the second.
Both arguments must be instances of TMEvent or a
ClassCastException will be thrown. The compareTo() method
of the first argument is used to do the comparison.
- Specified by:
compare
in interface java.util.Comparator
- Parameters:
object1
- The first event.object2
- The second event.
- Returns:
- -1, 0, or 1 if the first
argument is less than, equal to, or greater than the second.
- Throws:
java.lang.ClassCastException
- If one of the arguments is not
an instance of TMEvent.
getVirtualBinNumber
public final long getVirtualBinNumber(java.lang.Object event)
- Given an event, return the virtual index of
the bin that should contain the event.
If the argument is not an instance of TMEvent, then a
ClassCastException will be thrown. Only the priority
of the arguments is used. The quantity returned is the
quantized priority, i.e. the
difference between the priority of the event and that of
the zero reference, divided by the priority of the bin width.
- Specified by:
getVirtualBinNumber
in interface CQComparator
- Parameters:
event
- The event.
- Returns:
- The index of the virtual bin containing the event.
setBinWidth
public void setBinWidth(java.lang.Object[] entryArray)
- Do nothing.
- Specified by:
setBinWidth
in interface CQComparator
- Parameters:
entryArray
- An array of TMEvent objects.
setZeroReference
public void setZeroReference(java.lang.Object zeroReference)
- Do nothing.
- Specified by:
setZeroReference
in interface CQComparator
- Parameters:
zeroReference
- The zero reference of the comparator.