salvo.jesus.util
Class HeapNode

java.lang.Object
  extended by salvo.jesus.util.HeapNode
All Implemented Interfaces:
java.io.Serializable

public class HeapNode
extends java.lang.Object
implements java.io.Serializable

A node in a Heap, encapsulating the actual object represented by the noode plus the priority of the node in the heap.

Author:
Jesus M. Salvo Jr.
See Also:
Serialized Form

Field Summary
(package private)  java.lang.Object node
          The actual object encapsulated by the HeapNode.
(package private)  double priority
          The priority of the HeapNode
 
Constructor Summary
HeapNode(java.lang.Object node, double priority)
          Creates a HeapNode with a specified priority and encapsulating an object.
 
Method Summary
 java.lang.Object getObject()
          Returns the object encapsultaed by this HeapNode.
 double getPriority()
          Returns the priority of the HeapNode within the Heap.
 void setPriority(double priority)
          Modifies the priority of the HeapNode within the Heap.
 java.lang.String toString()
          Returns a String representation of this HeapNode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

node

java.lang.Object node
The actual object encapsulated by the HeapNode.


priority

double priority
The priority of the HeapNode

Constructor Detail

HeapNode

public HeapNode(java.lang.Object node,
                double priority)
Creates a HeapNode with a specified priority and encapsulating an object.

Parameters:
priority - The priority of the node in the heap, determining the position of the node within the heap.
node - The actual Object encapsulated by the node.
Method Detail

getObject

public java.lang.Object getObject()
Returns the object encapsultaed by this HeapNode.


getPriority

public double getPriority()
Returns the priority of the HeapNode within the Heap.


setPriority

public void setPriority(double priority)
Modifies the priority of the HeapNode within the Heap.

This method simply sets the priority attribute of the node. This will not necessarily fixup the Heap such that this HeapNode will be in its new position. To achieve that effect, call Heap.setPriority( HeapNode ).


toString

public java.lang.String toString()
Returns a String representation of this HeapNode.

Overrides:
toString in class java.lang.Object