E - type of the element hold by the red black tree node@StoreNotUseStandardSerialization @StorableClass public class RBTNode<E> extends Object implements IRBTNode<E>, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected Comparator<? super E> |
comparator
the comparator used to compare the element of this node, or null
if this node uses the natural comparator of its element
|
protected E |
element |
| Constructor and Description |
|---|
RBTNode() |
RBTNode(Comparator<? super E> comparator)
construct a empty node
|
RBTNode(E element)
a new node for an element
|
RBTNode(E element,
Comparator<? super E> comparator)
construct a empty node setting a comparator for this node element
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(IRBTVisitor<E> visitor)
accept red black tree visitor
|
int |
compareTo(E element) |
int |
compareTo(IRBTComparableNode<E> node) |
void |
decrementNumberOfChild() |
void |
detach()
detach the node from the tree
|
boolean |
equals(Object obj) |
boolean |
getColor()
get node color
color definition: RedBlackTree#BLACK and RedBlackTree#RED |
E |
getElement()
get the element of this node
|
int |
getIndex() |
IRBTNode<E> |
getLeft()
get left child of this node
|
int |
getNumberOfChild()
get the number of node in right and left tree node, sentinel excluded
|
IRBTNode<E> |
getParent()
get parent node
|
IRBTNode<E> |
getRight()
get right child of this node
|
int |
hashCode() |
void |
incrementNumberOfChild() |
boolean |
isAttached() |
boolean |
isBlack()
to know if node is black
|
boolean |
isColorSetted() |
boolean |
isRed()
to know if node is red
|
boolean |
isSentinel()
to know if this node is a sentinel ( a black leaf marker ), if not a
sentinel it is a valued node with right and left child
|
static RBTNode |
newInstance(IInstanceFactory instanceFactory) |
static RBTNode |
newInstance(IInstanceFactory instanceFactory,
Comparator comparator) |
static RBTNode |
newInstance(IInstanceFactory instanceFactory,
Object element) |
static RBTNode |
newInstance(IInstanceFactory instanceFactory,
Object element,
Comparator comparator) |
void |
setBlack()
set node color to black
|
void |
setColor(boolean color)
set node color
color definition: RedBlackTree#BLACK and RedBlackTree#RED |
void |
setElement(E element)
set this node element
|
void |
setIndex(int index) |
void |
setLeft(IRBTNode<E> node)
set left child of this node
|
void |
setNumberOfChild(int numberOfChild)
set the number of node in right and left tree node, sentinel excluded
|
void |
setParent(IRBTNode<E> node)
set parent node
|
void |
setRed()
set node color to red
|
void |
setRight(IRBTNode<E> node)
set right child of this node
|
String |
toString() |
protected E element
protected final Comparator<? super E> comparator
public RBTNode()
public RBTNode(Comparator<? super E> comparator)
comparator - the comparator to use on this node elementpublic RBTNode(E element)
element - element of this nodepublic RBTNode(E element, Comparator<? super E> comparator)
element - element of this nodecomparator - the comparator to use on this node elementpublic static RBTNode newInstance(IInstanceFactory instanceFactory)
public static RBTNode newInstance(IInstanceFactory instanceFactory, Comparator comparator)
public static RBTNode newInstance(IInstanceFactory instanceFactory, Object element)
public static RBTNode newInstance(IInstanceFactory instanceFactory, Object element, Comparator comparator)
public boolean isColorSetted()
isColorSetted in interface IRBTNode<E>public boolean isBlack()
throws RBTException
IRBTNodeisBlack in interface IRBTNode<E>RBTException - node access errorpublic void setBlack()
throws RBTException
IRBTNodesetBlack in interface IRBTNode<E>RBTExceptionpublic boolean isRed()
throws RBTException
IRBTNodeisRed in interface IRBTNode<E>RBTException - node access errorpublic void setRed()
throws RBTException
IRBTNodesetRed in interface IRBTNode<E>RBTException - node access errorpublic IRBTNode<E> getParent() throws RBTException
IRBTNodegetParent in interface IRBTNode<E>RBTException - node access errorpublic void setParent(IRBTNode<E> node) throws RBTException
IRBTNodesetParent in interface IRBTNode<E>node - the parent nodeRBTException - node access errorpublic IRBTNode<E> getLeft() throws RBTException
IRBTNodegetLeft in interface IRBTNode<E>RBTException - node access errorpublic void setLeft(IRBTNode<E> node) throws RBTException
IRBTNodesetLeft in interface IRBTNode<E>node - the left child of this nodeRBTException - node access errorpublic IRBTNode<E> getRight() throws RBTException
IRBTNodegetRight in interface IRBTNode<E>RBTException - node access errorpublic void setRight(IRBTNode<E> node) throws RBTException
IRBTNodesetRight in interface IRBTNode<E>node - the right child of this nodeRBTException - node access errorpublic E getElement()
IRBTNodegetElement in interface IRBTNode<E>public void setElement(E element)
IRBTNodesetElement in interface IRBTNode<E>element - the element to set for this nodepublic boolean isSentinel()
throws RBTException
IRBTNodeisSentinel in interface IRBTNode<E>RBTException - node access errorpublic boolean getColor()
throws RBTException
IRBTNodeRedBlackTree#BLACK and RedBlackTree#REDgetColor in interface IRBTNode<E>RBTException - node access errorpublic void setColor(boolean color)
throws RBTException
IRBTNodeRedBlackTree#BLACK and RedBlackTree#REDsetColor in interface IRBTNode<E>color - the node colorRBTException - node access errorpublic int getNumberOfChild()
throws RBTException
IRBTNodegetNumberOfChild in interface IRBTNode<E>RBTException - node access errorpublic void setNumberOfChild(int numberOfChild)
throws RBTException
IRBTNodesetNumberOfChild in interface IRBTNode<E>numberOfChild - the number of childrenRBTExceptionpublic void decrementNumberOfChild()
throws RBTException
decrementNumberOfChild in interface IRBTNode<E>RBTExceptionpublic void incrementNumberOfChild()
throws RBTException
incrementNumberOfChild in interface IRBTNode<E>RBTExceptionpublic void detach()
IRBTNodepublic boolean isAttached()
isAttached in interface IRBTNode<E>public int compareTo(IRBTComparableNode<E> node) throws RBTException
compareTo in interface IRBTComparableNode<E>RBTExceptionpublic int compareTo(E element) throws RBTException
compareTo in interface IRBTComparableNode<E>RBTExceptionpublic void accept(IRBTVisitor<E> visitor) throws RBTException
IRBTVisitableaccept in interface IRBTVisitable<E>visitor - the red black tree visitorRBTException - node access errorCopyright © 2007-2012 Luc Peuvrier. All Rights Reserved.