ptolemy.actor.util
Class SuperdenseTime

java.lang.Object
  extended by ptolemy.actor.util.SuperdenseTime
All Implemented Interfaces:
java.lang.Comparable

public class SuperdenseTime
extends java.lang.Object
implements java.lang.Comparable

This class defines the structure of superdense time used in domains having time involved in computation. A superdense time object, s, consists of a time stamp and an index, denoted as s = (t, n).

Two superdense time objects can be compared to see which one happens first. The order is defined by the relationship between their time stamps and indexes. In particular, given s_1 = (t_1, n_1) and s_2 = (t_2, n_2), s_1 happens earlier than s_2 (denoted as s_1 <= s_2), if t_1 < t_2 or (t_1 == t_2 and n_1 <= n_2). The equality relation holds only if both t_1 == t_2 and n_1 == n_2 hold.

Since:
Ptolemy II 5.2
Version:
$Id: SuperdenseTime.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Haiyang Zheng, Edward A. Lee
Accepted Rating:
Green (hyzheng)
Proposed Rating:
Green (hyzheng)

Field Summary
private  int _index
           
private  Time _timestamp
           
 
Constructor Summary
SuperdenseTime(Time timeStamp, int index)
          Construct a superdense time object with the specified timestamp and index.
 
Method Summary
 int compareTo(java.lang.Object superdenseTime)
          Compare this superdense time object with the argument superdense time object for an order.
 int compareTo(SuperdenseTime superdenseTime)
          Compare this superdense time object with the argument superdense time object for an order.
 int index()
          Return the index.
 Time timestamp()
          Return the timestamp.
 java.lang.String toString()
          Return a description of this superdense time object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_index

private int _index

_timestamp

private Time _timestamp
Constructor Detail

SuperdenseTime

public SuperdenseTime(Time timeStamp,
                      int index)
Construct a superdense time object with the specified timestamp and index.

Parameters:
timeStamp - The time stamp.
index - The index.
Method Detail

compareTo

public final int compareTo(java.lang.Object superdenseTime)
Compare this superdense time object with the argument superdense time object for an order. The argument has to be a superdense time object. Otherwise, a ClassCastException will be thrown.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
superdenseTime - The superdense time object to compare against.
Returns:
-1, 0, or 1, depending on the order of the events.
Throws:
java.lang.ClassCastException - If the argument is not a superdense time object.

compareTo

public final int compareTo(SuperdenseTime superdenseTime)
Compare this superdense time object with the argument superdense time object for an order. Return -1, 0, or 1 if this superdense time object happens earlier than, simultaneously with, or later than the argument superdense time object.

Their timestamps are compared first. If the two timestamps are not equal, their order defines the objects' order. Otherwise, the indexes are compared for the order, where the object with a smaller index happens earlier. If the two objects have the same timestamp and index, then they happen simultaneously.

Parameters:
superdenseTime - The superdense time object to compare against.
Returns:
-1, 0, or 1, depends on the order.

index

public final int index()
Return the index.

Returns:
The index.

timestamp

public final Time timestamp()
Return the timestamp.

Returns:
The timestamp.

toString

public final java.lang.String toString()
Return a description of this superdense time object.

Overrides:
toString in class java.lang.Object
Returns:
A description of this superdense time object.