com.mhhe.clrs2e
Class Activity

java.lang.Object
  |
  +--com.mhhe.clrs2e.Activity
All Implemented Interfaces:
java.lang.Comparable

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

A class for activities in the activity-selection problem of Section 16.1 of Introduction to Algorithms, Second edition.


Field Summary
private  double f
          Finish time.
private  double s
          Start time.
 
Constructor Summary
Activity(double startTime, double finishTime)
          Creates a new activity.
 
Method Summary
 boolean comesAfter(com.mhhe.clrs2e.Activity act)
          Returns a boolean value indicating whether this activity starts no earlier than another finishes.
 int compareTo(java.lang.Object o)
          Compares this activity to another, based on their finish times.
 java.lang.String toString()
          Returns the String representation of this activity, using half-open interval notation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

s

private double s
Start time.


f

private double f
Finish time.

Constructor Detail

Activity

public Activity(double startTime,
                double finishTime)
Creates a new activity.

Parameters:
startTime - Start time.
finishTime - Finish time.
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares this activity to another, based on their finish times.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The other activity.
Returns:
-1 if this activity finishes first, 0 if the two activities have the same finish time, 1 if the other activity finishes first.
Throws:
java.lang.ClassCastException - if o does not reference an Activity object.

comesAfter

public boolean comesAfter(com.mhhe.clrs2e.Activity act)
Returns a boolean value indicating whether this activity starts no earlier than another finishes.

Parameters:
act - The other activity.
Returns:
true if this activity starts no earlier than act finishes.

toString

public java.lang.String toString()
Returns the String representation of this activity, using half-open interval notation.

Overrides:
toString in class java.lang.Object