public static class TimedEvent.TimeComparator extends java.lang.Object implements CQComparator
| Constructor and Description |
|---|
TimeComparator()
Construct a TimeComparator object.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
public int compare(java.lang.Object object1,
java.lang.Object object2)
compare in interface java.util.Comparatorobject1 - 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 CQComparatorentry - The entry.java.lang.ClassCastException - If the arguments are not instances of
TimedEvent.public void setBinWidth(java.lang.Object[] entryArray)
setBinWidth in interface CQComparatorentryArray - 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 CQComparatorzeroReference - The starting point for bins.java.lang.ClassCastException - If the argument is not an instance
of TimedEvent.