heaps.event
Class TimeAssociation<T>

java.lang.Object
  extended by heaps.event.TimeAssociation<T>
Type Parameters:
T - the class of the object in the association

public class TimeAssociation<T>
extends java.lang.Object

An class representing an association between an object and a specified time. Typically, the time is in units of milliseconds. No natural ordering is defined on TimeAssociation objects, but one can be imposed by the comparators returned by static methods getMinComparator and getMaxComparator.

Author:
Michael Parker

Constructor Summary
TimeAssociation(T _obj, long _time)
          Creates a new association between object _obj and time _time.
 
Method Summary
 boolean equals(java.lang.Object arg)
          Returns whether this TimeAssociation object is equal to arg.
static java.util.Comparator<TimeAssociation> getMaxComparator()
          Returns a comparator such that for two TimeAssociation objects ta1 and ta2, ta1 < ta2 if and only if ta1.getTime() > ta2.getTime.
static java.util.Comparator<TimeAssociation> getMinComparator()
          Returns a comparator such that for two TimeAssociation objects ta1 and ta2, ta1 < ta2 if and only if ta1.getTime() < ta2.getTime.
 T getObject()
          Returns the object in this association.
 long getTime()
          Returns the time in this association.
 int hashCode()
          Returns the hash code of this object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeAssociation

public TimeAssociation(T _obj,
                       long _time)
Creates a new association between object _obj and time _time.

Parameters:
_obj - the object in the association
_time - the time in the association
Method Detail

getMinComparator

public static java.util.Comparator<TimeAssociation> getMinComparator()
Returns a comparator such that for two TimeAssociation objects ta1 and ta2, ta1 < ta2 if and only if ta1.getTime() < ta2.getTime.

Returns:
a min-comparator for TimeAssociation elements

getMaxComparator

public static java.util.Comparator<TimeAssociation> getMaxComparator()
Returns a comparator such that for two TimeAssociation objects ta1 and ta2, ta1 < ta2 if and only if ta1.getTime() > ta2.getTime.

Returns:
a max-comparator for TimeAssociation elements

getObject

public T getObject()
Returns the object in this association.

Returns:
the associated object

getTime

public long getTime()
Returns the time in this association.

Returns:
the associated time

equals

public boolean equals(java.lang.Object arg)
Returns whether this TimeAssociation object is equal to arg. This method and the provided argument are equal if the argument is of type TimeAssociation, their times as returned by method getTime on each are equal, and their contained objects as returned by method getObject on each are equivalent by method equals.

Overrides:
equals in class java.lang.Object
Returns:
true if this object is equal to arg, false otherwise

hashCode

public int hashCode()
Returns the hash code of this object. The returned hash code is both dependent on the associated time and the hash code of the associated object.

Overrides:
hashCode in class java.lang.Object