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
IRBTNode
isBlack
in interface IRBTNode<E>
RBTException
- node access errorpublic void setBlack() throws RBTException
IRBTNode
setBlack
in interface IRBTNode<E>
RBTException
public boolean isRed() throws RBTException
IRBTNode
isRed
in interface IRBTNode<E>
RBTException
- node access errorpublic void setRed() throws RBTException
IRBTNode
setRed
in interface IRBTNode<E>
RBTException
- node access errorpublic IRBTNode<E> getParent() throws RBTException
IRBTNode
getParent
in interface IRBTNode<E>
RBTException
- node access errorpublic void setParent(IRBTNode<E> node) throws RBTException
IRBTNode
setParent
in interface IRBTNode<E>
node
- the parent nodeRBTException
- node access errorpublic IRBTNode<E> getLeft() throws RBTException
IRBTNode
getLeft
in interface IRBTNode<E>
RBTException
- node access errorpublic void setLeft(IRBTNode<E> node) throws RBTException
IRBTNode
setLeft
in interface IRBTNode<E>
node
- the left child of this nodeRBTException
- node access errorpublic IRBTNode<E> getRight() throws RBTException
IRBTNode
getRight
in interface IRBTNode<E>
RBTException
- node access errorpublic void setRight(IRBTNode<E> node) throws RBTException
IRBTNode
setRight
in interface IRBTNode<E>
node
- the right child of this nodeRBTException
- node access errorpublic E getElement()
IRBTNode
getElement
in interface IRBTNode<E>
public void setElement(E element)
IRBTNode
setElement
in interface IRBTNode<E>
element
- the element to set for this nodepublic boolean isSentinel() throws RBTException
IRBTNode
isSentinel
in interface IRBTNode<E>
RBTException
- node access errorpublic boolean getColor() throws RBTException
IRBTNode
RedBlackTree#BLACK
and RedBlackTree#RED
getColor
in interface IRBTNode<E>
RBTException
- node access errorpublic void setColor(boolean color) throws RBTException
IRBTNode
RedBlackTree#BLACK
and RedBlackTree#RED
setColor
in interface IRBTNode<E>
color
- the node colorRBTException
- node access errorpublic int getNumberOfChild() throws RBTException
IRBTNode
getNumberOfChild
in interface IRBTNode<E>
RBTException
- node access errorpublic void setNumberOfChild(int numberOfChild) throws RBTException
IRBTNode
setNumberOfChild
in interface IRBTNode<E>
numberOfChild
- the number of childrenRBTException
public void decrementNumberOfChild() throws RBTException
decrementNumberOfChild
in interface IRBTNode<E>
RBTException
public void incrementNumberOfChild() throws RBTException
incrementNumberOfChild
in interface IRBTNode<E>
RBTException
public void detach()
IRBTNode
public boolean isAttached()
isAttached
in interface IRBTNode<E>
public int compareTo(IRBTComparableNode<E> node) throws RBTException
compareTo
in interface IRBTComparableNode<E>
RBTException
public int compareTo(E element) throws RBTException
compareTo
in interface IRBTComparableNode<E>
RBTException
public void accept(IRBTVisitor<E> visitor) throws RBTException
IRBTVisitable
accept
in interface IRBTVisitable<E>
visitor
- the red black tree visitorRBTException
- node access errorCopyright © 2007-2012 Luc Peuvrier. All Rights Reserved.