heaps.event
Class ComparableTimeAssociation<T>

java.lang.Object
  extended by heaps.event.ComparableTimeAssociation<T>
Type Parameters:
T - the class of the object in the association
All Implemented Interfaces:
java.lang.Comparable<ComparableTimeAssociation<T>>

public class ComparableTimeAssociation<T>
extends java.lang.Object
implements java.lang.Comparable<ComparableTimeAssociation<T>>

An class representing an association between an object and a specified time. Typically, the time is in units of milliseconds. A natural ordering is defined between ComparableTimeAssociation objects by their associated time.

Author:
Michael Parker

Constructor Summary
ComparableTimeAssociation(T _obj, long _time)
          Creates a new association between object _obj and time _time.
 
Method Summary
 int compareTo(ComparableTimeAssociation<T> ta)
          Compares the time of this TimeAssociation object with the time of TimeAssociation object ta.
 boolean equals(java.lang.Object arg)
          Returns whether this TimeAssociation object is equal to arg.
 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

ComparableTimeAssociation

public ComparableTimeAssociation(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

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

compareTo

public int compareTo(ComparableTimeAssociation<T> ta)
Compares the time of this TimeAssociation object with the time of TimeAssociation object ta.

Specified by:
compareTo in interface java.lang.Comparable<ComparableTimeAssociation<T>>
Parameters:
ta - another TimeAssociation object whose time this object should compare against
Returns:
0 if the time of this object is equal to the time of ta; -1 if the time of this object is less than the time of ta; and 1 if the time of this object is greater than the time of ta

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 and their times as returned by method getTime on each are equal.

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 dependent only on the associated time.

Overrides:
hashCode in class java.lang.Object