m865.datastructures
Class PrioritizedItem

java.lang.Object
  extended by m865.datastructures.PrioritizedItem
All Implemented Interfaces:
java.lang.Comparable, Prioritizeable

public class PrioritizedItem
extends java.lang.Object
implements Prioritizeable

The PrioritizedItem class contains objects which consist of a comparable object which represents the explicit priority, and a general object which is the prioritized datum.


Field Summary
protected  java.lang.Object datum
          The general object which the datum.
protected  java.lang.Comparable priority
          The Comparable object which designates the priority.
 
Constructor Summary
PrioritizedItem()
          Default constuctor
PrioritizedItem(java.lang.Comparable p, java.lang.Object obj)
          General Constructor
 
Method Summary
 boolean adjustPriority(java.lang.Comparable p)
          Adjusts the priority of this object
 java.lang.Object clone()
          Creates a clone of this object
 int compareTo(java.lang.Object pqi)
          The compareTo method required by the Comparable interface If the priorities are comparable this returns an int specifying the relation between the two priorities.
 boolean equals(java.lang.Object obj)
          Tests for the equality of this object with a specified object
 java.lang.Object getDatum()
          Get the datum of this object
 java.lang.Comparable getPriority()
          Get the priority of this object
 int hashCode()
          Calculates the hashCode
 void setDatum(java.lang.Object obj)
          Set the dataum of this object
 void setPriority(java.lang.Comparable p)
          Set the priority of this object
 java.lang.String toString()
          Display this prioritized item
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

priority

protected java.lang.Comparable priority
The Comparable object which designates the priority.


datum

protected java.lang.Object datum
The general object which the datum.

Constructor Detail

PrioritizedItem

public PrioritizedItem(java.lang.Comparable p,
                       java.lang.Object obj)
General Constructor

Parameters:
p - the priority of the Prioritized item
obj - the datum of the Prioritized item

PrioritizedItem

public PrioritizedItem()
Default constuctor

Method Detail

setPriority

public void setPriority(java.lang.Comparable p)
Set the priority of this object

Parameters:
p - the priority

getPriority

public java.lang.Comparable getPriority()
Get the priority of this object

Returns:
the Comparable object which represents the priority

setDatum

public void setDatum(java.lang.Object obj)
Set the dataum of this object

Parameters:
obj - the datum of this object

getDatum

public java.lang.Object getDatum()
Get the datum of this object

Returns:
the Object which is the datum

adjustPriority

public boolean adjustPriority(java.lang.Comparable p)
Adjusts the priority of this object

Specified by:
adjustPriority in interface Prioritizeable
Parameters:
p - the new priority
Returns:
true if the new priority is precedes the old priority.

compareTo

public int compareTo(java.lang.Object pqi)
The compareTo method required by the Comparable interface If the priorities are comparable this returns an int specifying the relation between the two priorities.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
pqi - the specified object which should be a PrioritizedItem
Returns:
a negative integer if this object should appear before the specified object in a sorted list; zero if this object is equal to the specified object; and a positive integer if this object should appear after the specified object in a sorted list.

clone

public java.lang.Object clone()
Creates a clone of this object

Overrides:
clone in class java.lang.Object
Returns:
a copy of the pair of reference variables constituting this PrioritizedItem.

equals

public boolean equals(java.lang.Object obj)
Tests for the equality of this object with a specified object

Overrides:
equals in class java.lang.Object
Parameters:
obj - the specified object
Returns:
true if this object is equal to the specified object

hashCode

public int hashCode()
Calculates the hashCode

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code for this composite object

toString

public java.lang.String toString()
Display this prioritized item

Overrides:
toString in class java.lang.Object
Returns:
a formatted string listing the two pieces of this composite object