Package ptolemy.actor.util
Class SuperdenseTime
- java.lang.Object
-
- 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$
- Author:
- Haiyang Zheng, Edward A. Lee
- Pt.AcceptedRating:
- Green (hyzheng)
- Pt.ProposedRating:
- Green (hyzheng)
-
-
Constructor Summary
Constructors Constructor Description SuperdenseTime(Time timeStamp, int index)
Construct a superdense time object with the specified timestamp and index.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.boolean
equals(java.lang.Object superdenseTime)
Return true if this SuperdenseTime object has the same timestamp and index as that of the given SuperdenseTime object.int
hashCode()
Return the hash code for the SuperdenseTime object.int
index()
Return the index.Time
timestamp()
Return the timestamp.java.lang.String
toString()
Return a description of this superdense time object.
-
-
-
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 interfacejava.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.
-
equals
public boolean equals(java.lang.Object superdenseTime)
Return true if this SuperdenseTime object has the same timestamp and index as that of the given SuperdenseTime object.- Overrides:
equals
in classjava.lang.Object
- Parameters:
superdenseTime
- The SuperDenseTime object that this SuperdenseTime object is compared to.- Returns:
- True if the two SuperDenseTime objects have the same timestamp and index.
-
hashCode
public int hashCode()
Return the hash code for the SuperdenseTime object. If two SuperdenseTime objects contains the same timestamp and index, then they have the same hashcode.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code for this SuperdenseTime object.
-
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 classjava.lang.Object
- Returns:
- A description of this superdense time object.
-
-