iterator
Class pnodePQ

java.lang.Object
  extended byiterator.pnodePQ
Direct Known Subclasses:
pnodeSplayPQ

public abstract class pnodePQ
extends java.lang.Object

Implements a sorted binary tree. abstract methods enq and deq are used to add or remove elements from the tree.


Constructor Summary
pnodePQ()
          class constructor, set count to 0.
 
Method Summary
abstract  pnode deq()
          removes the minimum (Ascending) or maximum (Descending) element from the tree.
 boolean empty()
          tests whether the tree is empty
abstract  void enq(pnode item)
          insert an element in the tree in the correct order.
 int length()
          returns the number of elements in the tree.
 int pnodeCMP(pnode a, pnode b)
          compares two elements.
 boolean pnodeEQ(pnode a, pnode b)
          tests whether the two elements are equal.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

pnodePQ

public pnodePQ()
class constructor, set count to 0.

Method Detail

length

public int length()
returns the number of elements in the tree.

Returns:
number of elements in the tree.

empty

public boolean empty()
tests whether the tree is empty

Returns:
true if tree is empty, false otherwise

enq

public abstract void enq(pnode item)
                  throws java.io.IOException,
                         UnknowAttrType,
                         TupleUtilsException
insert an element in the tree in the correct order.

Parameters:
item - the element to be inserted
Throws:
java.io.IOException - from lower layers
UnknowAttrType - attrSymbol or attrNull encountered
TupleUtilsException - error in tuple compare routines

deq

public abstract pnode deq()
removes the minimum (Ascending) or maximum (Descending) element from the tree.

Returns:
the element removed, null if the tree is empty

pnodeCMP

public int pnodeCMP(pnode a,
                    pnode b)
             throws java.io.IOException,
                    UnknowAttrType,
                    TupleUtilsException
compares two elements.

Parameters:
a - one of the element for comparison
b - the other element for comparison
Returns:
0 if the two are equal, 1 if a is greater, -1 if b is greater
Throws:
java.io.IOException - from lower layers
UnknowAttrType - attrSymbol or attrNull encountered
TupleUtilsException - error in tuple compare routines

pnodeEQ

public boolean pnodeEQ(pnode a,
                       pnode b)
                throws java.io.IOException,
                       UnknowAttrType,
                       TupleUtilsException
tests whether the two elements are equal.

Parameters:
a - one of the element for comparison
b - the other element for comparison
Returns:
true if a == b, false otherwise
Throws:
java.io.IOException - from lower layers
UnknowAttrType - attrSymbol or attrNull encountered
TupleUtilsException - error in tuple compare routines