|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.actor.util.TimedEvent.TimeComparator
public static class TimedEvent.TimeComparator
This class implements the CQComparator interface. It compares instances of TimedEvent. Therefore, all arguments passed to its methods have to be of type TimedEvent (or TimedEvent[] for the getBinWidth() method). If this is violated, ClassCastException will be thrown.
Field Summary | |
---|---|
private double |
_binWidth
|
private double |
_zeroReference
|
Constructor Summary | |
---|---|
TimedEvent.TimeComparator()
Construct a TimeComparator object. |
Method Summary | |
---|---|
int |
compare(java.lang.Object object1,
java.lang.Object object2)
Compare the two arguments. |
long |
getVirtualBinNumber(java.lang.Object entry)
Given an entry, return a virtual bin number for the entry. |
void |
setBinWidth(java.lang.Object[] entryArray)
Given an array of TimedEvent objects, find the appropriate bin width. |
void |
setZeroReference(java.lang.Object zeroReference)
Set the zero reference, to be used in calculating the virtual bin number. |
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 |
Field Detail |
---|
private double _binWidth
private double _zeroReference
Constructor Detail |
---|
public TimedEvent.TimeComparator()
Method Detail |
---|
public int compare(java.lang.Object object1, java.lang.Object object2)
compare
in interface java.util.Comparator
object1
- The first event.object2
- The second event.
java.lang.ClassCastException
- If either argument is not an instance
of TimedEvent.public long getVirtualBinNumber(java.lang.Object entry)
(entry.timeStamp - zeroReference) / binWidth,
with the result cast to long. If the arguments are not instances of TimedEvent, then a ClassCastException will be thrown. If the bin number is larger than what can be represented in a long, then the low-order 64 bits will be returned. Note that this could change the sign of the result, but the way this is used in the CalendarQueue class, this is OK. It is converted to a bin number by masking some number of low-order bits, so the result will be unaffected by the sign error.
getVirtualBinNumber
in interface CQComparator
entry
- The entry.
java.lang.ClassCastException
- If the arguments are not instances of
TimedEvent.public void setBinWidth(java.lang.Object[] entryArray)
setBinWidth
in interface CQComparator
entryArray
- An array of TimedEvent objects.
java.lang.ClassCastException
- If one of the array elements is not
an instance of TimedEvent.public void setZeroReference(java.lang.Object zeroReference)
setZeroReference
in interface CQComparator
zeroReference
- The starting point for bins.
java.lang.ClassCastException
- If the argument is not an instance
of TimedEvent.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |