Package 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$
- Author:
- Jie Liu
- Pt.AcceptedRating:
- Yellow (janneck)
- Pt.ProposedRating:
- Yellow (liuj)
-
-
Constructor Summary
Constructors Constructor Description TMEventComparator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(java.lang.Object object1, java.lang.Object object2)Compare the two argument for order.longgetVirtualBinNumber(java.lang.Object event)Given an event, return the virtual index of the bin that should contain the event.voidsetBinWidth(java.lang.Object[] entryArray)Do nothing.voidsetZeroReference(java.lang.Object zeroReference)Do nothing.
-
-
-
Method Detail
-
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:
comparein interfacejava.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:
getVirtualBinNumberin interfaceCQComparator- 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:
setBinWidthin interfaceCQComparator- Parameters:
entryArray- An array of TMEvent objects.
-
setZeroReference
public void setZeroReference(java.lang.Object zeroReference)
Do nothing.- Specified by:
setZeroReferencein interfaceCQComparator- Parameters:
zeroReference- The zero reference of the comparator.
-
-