edu.neu.ccs.demeterf.lib
Class RBNode<X extends java.lang.Comparable<X>>

java.lang.Object
  extended by edu.neu.ccs.demeterf.lib.RBTree<X>
      extended by edu.neu.ccs.demeterf.lib.RBNode<X>
All Implemented Interfaces:
java.lang.Iterable<X>

public class RBNode<X extends java.lang.Comparable<X>>
extends RBTree<X>

Represents a Node of an RBTree, e.g., the non-empty tree


Nested Class Summary
static class RBNode.color
           
static class RBNode.data
           
static class RBNode.left
           
static class RBNode.right
           
 
Constructor Summary
RBNode(RBColor color, X data, RBTree<X> left, RBTree<X> right)
           
 
Method Summary
 boolean contains(X x, java.util.Comparator<X> comp)
          Is the given element in this RBTree, using the given Comparator?
 boolean containsAll(RBTree<X> x, java.util.Comparator<X> comp)
          Are all the elements int the given RBTree contained in this RBTree, using the given Comparator?
 boolean equals(java.lang.Object o)
           
 X find(X x, java.util.Comparator<X> comp)
          Return the X in this RBTree that matches the given one, using the given Comparator
 int hashCode()
           
 boolean isLeaf()
          Is this RBTree a leaf?
 X max()
          Return this RBTree's maximum element (Only valid on RBNodes)
 X min()
          Return this RBTree's minimum element (Only valid on RBNodes)
 X pred()
          Return this RBTree's predicessor element (Only valid on RBNodes)
 RBTree<X> remove(X x, java.util.Comparator<X> c)
          Return this RBTree without the given element, using the given Comparator
 RBTree<X> replace(X x, java.util.Comparator<X> comp)
          Return a new RBTree without the given element, using the given Comparator
 int size()
          Return the number of elements in the RBTree
 X succ()
          Return this RBTree's successor element (Only valid on RBNodes)
 List<X> toList()
          Return all the elements in thei RBTree as a List in order
 java.lang.String toString()
           
 
Methods inherited from class edu.neu.ccs.demeterf.lib.RBTree
black, contains, containsAll, create, create, find, insert, insert, insertAll, insertAll, insertAll, insertAll, iterator, leaf, node, red, remove, replace
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RBNode

public RBNode(RBColor color,
              X data,
              RBTree<X> left,
              RBTree<X> right)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

isLeaf

public boolean isLeaf()
Description copied from class: RBTree
Is this RBTree a leaf?

Specified by:
isLeaf in class RBTree<X extends java.lang.Comparable<X>>

contains

public boolean contains(X x,
                        java.util.Comparator<X> comp)
Description copied from class: RBTree
Is the given element in this RBTree, using the given Comparator?

Specified by:
contains in class RBTree<X extends java.lang.Comparable<X>>

containsAll

public boolean containsAll(RBTree<X> x,
                           java.util.Comparator<X> comp)
Description copied from class: RBTree
Are all the elements int the given RBTree contained in this RBTree, using the given Comparator?

Specified by:
containsAll in class RBTree<X extends java.lang.Comparable<X>>

find

public X find(X x,
              java.util.Comparator<X> comp)
Description copied from class: RBTree
Return the X in this RBTree that matches the given one, using the given Comparator

Specified by:
find in class RBTree<X extends java.lang.Comparable<X>>

remove

public RBTree<X> remove(X x,
                        java.util.Comparator<X> c)
Description copied from class: RBTree
Return this RBTree without the given element, using the given Comparator

Specified by:
remove in class RBTree<X extends java.lang.Comparable<X>>

toList

public List<X> toList()
Description copied from class: RBTree
Return all the elements in thei RBTree as a List in order

Specified by:
toList in class RBTree<X extends java.lang.Comparable<X>>

size

public int size()
Description copied from class: RBTree
Return the number of elements in the RBTree

Specified by:
size in class RBTree<X extends java.lang.Comparable<X>>

pred

public X pred()
Description copied from class: RBTree
Return this RBTree's predicessor element (Only valid on RBNodes)

Specified by:
pred in class RBTree<X extends java.lang.Comparable<X>>

succ

public X succ()
Description copied from class: RBTree
Return this RBTree's successor element (Only valid on RBNodes)

Specified by:
succ in class RBTree<X extends java.lang.Comparable<X>>

min

public X min()
Description copied from class: RBTree
Return this RBTree's minimum element (Only valid on RBNodes)

Specified by:
min in class RBTree<X extends java.lang.Comparable<X>>

max

public X max()
Description copied from class: RBTree
Return this RBTree's maximum element (Only valid on RBNodes)

Specified by:
max in class RBTree<X extends java.lang.Comparable<X>>

replace

public RBTree<X> replace(X x,
                         java.util.Comparator<X> comp)
Description copied from class: RBTree
Return a new RBTree without the given element, using the given Comparator

Specified by:
replace in class RBTree<X extends java.lang.Comparable<X>>

hashCode

public int hashCode()
Specified by:
hashCode in class RBTree<X extends java.lang.Comparable<X>>