Class comparable

java.lang.Object
  |
  +--comparable
Direct Known Subclasses:
intComparable, StringComparable

public abstract class comparable
extends java.lang.Object

The comparable class provides a template for comaprable objects. The list is initialized by the constructor and the comp method is declared. Note that this method essentially does nothing. Because the nature of the datais not clear at this level no comparison operation is acutually scarried out. It is left to classes extending the comparable class toprovide the code for comp method. This way of implementing the method is not clean (returning 0 just becaus ewe have to return something.) A better way is to use abstract tag for comp method (as well as the comparable class itself). The source code


Field Summary
protected  java.lang.Object[] list
           
 
Constructor Summary
comparable(java.lang.Object[] list)
           
 
Method Summary
 java.lang.Object getListItem(int i)
          Get the i'th item of the list.
 void setListItem(int i, java.lang.Object A)
          Put A in the i'th position of the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

list

protected java.lang.Object[] list
Constructor Detail

comparable

public comparable(java.lang.Object[] list)
Method Detail

getListItem

public java.lang.Object getListItem(int i)
Get the i'th item of the list.

setListItem

public void setListItem(int i,
                        java.lang.Object A)
Put A in the i'th position of the list.