@NotStorableClass public abstract class AbstractHeapRecordableRBTNode<E> extends AbstractHeapRecordable implements IRBTNode<E>
Modifier and Type | Field and Description |
---|---|
protected static int |
headerByteSize |
heapRecordableManager, helperBinaryConversion, logger
Constructor and Description |
---|
AbstractHeapRecordableRBTNode(HeapRecordableManager heapRecordableManager,
HelperBinaryConversion helperBinaryConversion) |
AbstractHeapRecordableRBTNode(HelperBinaryConversion helperBinaryConversion)
construct a sentinel
|
Modifier and Type | Method and Description |
---|---|
void |
accept(IRBTVisitor<E> visitor)
accept red black tree visitor
|
int |
byteSize() |
protected abstract int |
byteSize(E element) |
protected void |
checkNotSentinel() |
int |
compareTo(E element) |
int |
compareTo(IRBTComparableNode<E> node) |
void |
decrementNumberOfChild() |
void |
detach()
detach the node from the tree
|
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
|
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
|
void |
marshall(byte[] binary)
from object state to binary form
|
protected abstract void |
marshallElement(byte[] binary,
int offset,
E element) |
protected abstract AbstractHeapRecordableRBTNode<E> |
newNode(HeapRecordableManager heapRecordableManager) |
protected abstract AbstractHeapRecordableRBTNode<E> |
newSentinel() |
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
|
void |
setStateHaveChanged()
set state changed,
HeapRecordableManager will save change |
String |
toString() |
void |
unmarshall(byte[] binary)
from binary form to object state
|
protected abstract E |
unmarshallElement(byte[] binary,
int offset) |
checkLoaded, clear, compareTo, equals, getDataRecordIdentifier, hashCode, isStateChanged, setDataRecordIdentifier, setSynchronizedWithFile
protected static final int headerByteSize
public AbstractHeapRecordableRBTNode(HeapRecordableManager heapRecordableManager, HelperBinaryConversion helperBinaryConversion)
public AbstractHeapRecordableRBTNode(HelperBinaryConversion helperBinaryConversion)
public int byteSize() throws HeapRecordableException
byteSize
in interface IHeapRecordable
HeapRecordableException
protected abstract int byteSize(E element) throws HeapRecordableException
HeapRecordableException
public void marshall(byte[] binary) throws HeapRecordableException
IHeapRecordable
marshall
in interface IHeapRecordable
binary
- where write the object stateHeapRecordableException
protected abstract void marshallElement(byte[] binary, int offset, E element) throws BinaryConverterException
BinaryConverterException
public void unmarshall(byte[] binary) throws HeapRecordableException
IHeapRecordable
unmarshall
in interface IHeapRecordable
binary
- where read the object stateHeapRecordableException
protected abstract AbstractHeapRecordableRBTNode<E> newNode(HeapRecordableManager heapRecordableManager)
protected abstract AbstractHeapRecordableRBTNode<E> newSentinel()
protected abstract E unmarshallElement(byte[] binary, int offset) throws HeapRecordableException
HeapRecordableException
protected void checkNotSentinel() throws RBTException
RBTException
public void setStateHaveChanged() throws HeapRecordableException
AbstractHeapRecordable
HeapRecordableManager
will save changesetStateHaveChanged
in class AbstractHeapRecordable
HeapRecordableException
public boolean isColorSetted() throws RBTException
isColorSetted
in interface IRBTNode<E>
RBTException
public boolean getColor() throws RBTException
IRBTNode
RedBlackTree#BLACK
and RedBlackTree#RED
getColor
in interface IRBTNode<E>
RBTException
- node access errorpublic IRBTNode<E> getLeft() throws RBTException
IRBTNode
getLeft
in interface IRBTNode<E>
RBTException
- node access errorpublic IRBTNode<E> getParent() throws RBTException
IRBTNode
getParent
in interface IRBTNode<E>
RBTException
- node access errorpublic IRBTNode<E> getRight() throws RBTException
IRBTNode
getRight
in interface IRBTNode<E>
RBTException
- node access errorpublic boolean isBlack() throws RBTException
IRBTNode
isBlack
in interface IRBTNode<E>
RBTException
- node access errorpublic boolean isRed() throws RBTException
IRBTNode
isRed
in interface IRBTNode<E>
RBTException
- node access errorpublic boolean isSentinel() throws RBTException
IRBTNode
isSentinel
in interface IRBTNode<E>
RBTException
- node access errorpublic void setBlack() throws RBTException
IRBTNode
setBlack
in interface IRBTNode<E>
RBTException
public void setColor(boolean color) throws RBTException
IRBTNode
RedBlackTree#BLACK
and RedBlackTree#RED
setColor
in interface IRBTNode<E>
color
- the node colorRBTException
- 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 void setNumberOfChild(int numberOfChild) throws RBTException
IRBTNode
setNumberOfChild
in interface IRBTNode<E>
numberOfChild
- the number of childrenRBTException
public int getNumberOfChild() throws RBTException
IRBTNode
getNumberOfChild
in interface IRBTNode<E>
RBTException
- node access errorpublic void decrementNumberOfChild() throws RBTException
decrementNumberOfChild
in interface IRBTNode<E>
RBTException
public void incrementNumberOfChild() throws RBTException
incrementNumberOfChild
in interface IRBTNode<E>
RBTException
public void setParent(IRBTNode<E> node) throws RBTException
IRBTNode
setParent
in interface IRBTNode<E>
node
- the parent nodeRBTException
- node access errorpublic void setRed() throws RBTException
IRBTNode
setRed
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 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 errorpublic E getElement() throws RBTException
IRBTNode
getElement
in interface IRBTNode<E>
RBTException
public void setElement(E element) throws RBTException
IRBTNode
setElement
in interface IRBTNode<E>
element
- the element to set for this nodeRBTException
public void detach()
IRBTNode
public boolean isAttached()
isAttached
in interface IRBTNode<E>
public String toString()
toString
in class AbstractHeapRecordable
Copyright © 2007-2012 Luc Peuvrier. All Rights Reserved.