|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CQComparator
This interface extends the java.util.Comparator interface, which defines the compare() method. The extension defines additional methods that specifically support the CalendarQueue class. That class needs to associate an entry in the queue with a virtual bin number, and needs to be able to periodically recompute the width of its bins. Thus, merely being able to compare entries is not sufficient.
CalendarQueue
,
Comparator
Yellow (liuj) |
Green (eal) |
Method Summary | |
---|---|
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 entries, set an appropriate bin width for a calendar queue to hold these entries. |
void |
setZeroReference(java.lang.Object zeroReference)
Set the zero reference, to be used in calculating the virtual bin number. |
Methods inherited from interface java.util.Comparator |
---|
compare, equals |
Method Detail |
---|
long getVirtualBinNumber(java.lang.Object entry)
(entry - zeroReference) / binWidth,
with the result cast to long.Because of the way this is used by CalendarQueue, it is OK to return the low order 64 bits of the result if the result does not fit in 64 bits. The result will be masked anyway to get fewer low order bits that represent the bin number. As a net result, time stamps that differ by exactly 2^64 times the time resolution will appear in the event queue to be occurring at the same time.
Classes that implement this interface will in general need to perform a downcast on the arguments (of type Object) to the appropriate user defined classes. If the arguments are not of appropriate type, the implementation should throw a ClassCastException.
entry
- An object that can be inserted in a calendar queue.
void setBinWidth(java.lang.Object[] entryArray)
entryArray
- An array of entries.void setZeroReference(java.lang.Object zeroReference)
zeroReference
- The starting point for bins.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |