com.mhhe.clrs2e
Interface DynamicSetElement

All Superinterfaces:
java.lang.Comparable
All Known Implementing Classes:
Dijkstra.DijkstraInfo, Huffman.InternalNode, Huffman.Node, Huffman.PrefixCodeItem, Prim.PrimInfo

public interface DynamicSetElement
extends java.lang.Comparable

Interface for an element in a dynamic set. We can get and set a key, which is a Comparable object, and we can compare dynamic-set elements to other dynamic-set elements and, depending on the implmentation, to arbitrary Comparable objects.


Nested Class Summary
static class DynamicSetElement.Helper
          Inner class to define static helper methods.
 
Method Summary
 int compareTo(java.lang.Object e)
          Compares this DynamicSetElement to another object.
 java.lang.Comparable getKey()
          Returns the key of an element.
 void setKey(java.lang.Comparable key)
          Sets the key of an element.
 

Method Detail

setKey

public void setKey(java.lang.Comparable key)
Sets the key of an element.

Parameters:
key - Key to be set.

getKey

public java.lang.Comparable getKey()
Returns the key of an element.


compareTo

public int compareTo(java.lang.Object e)
Compares this DynamicSetElement to another object. The normal implementation is simply return DynamicSetElement.Helper.compareTo(this, e);

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
e - The other object.
Returns:
A negative integer if this DynamicSetElement is less; 0 if the objects are equal; a positive integer if this DynamicSetElement is greater.
Throws:
java.lang.ClassCastException - if the implementation calls DynamicSetElement.Helper.compareTo(this, e) and e does not implement Comparable.