@NotStorableClass public abstract class AbstractHeapRBTNode<E extends Comparable<E>> extends Object implements IRBTNode<E>
IRBTNode
where an association is made between
this node and its image in heap fileModifier and Type | Field and Description |
---|---|
boolean |
color
this node color:
RedBlackTree.BLACK or RedBlackTree.RED . |
boolean |
colorSetted
true if node color set. public is bad smell but this done for
optimization
|
protected IHeapElementManager |
heapElementManager
heap elements manager for access to
HeapRecord , null for sentinel
node |
int |
index |
long |
leftPositionInFile
position in heap file of the copy of this node left son. public is bad
smell but this done for optimization
|
int |
numberOfChild
number of child of this node. public is bad smell but this done for
optimization
|
long |
parentPositionInFile
position in heap file of the copy of this node parent. public is bad
smell but this done for optimization
|
long |
rightPositionInFile
position in heap file of the copy of this node right son. public is bad
smell but this done for optimization
|
boolean |
valueChanged
became true when value changed. public is bad smell but this done for
optimization
|
Constructor and Description |
---|
AbstractHeapRBTNode(IHeapElementManager heapElementManager,
long positionInFile,
long parentPositionInFile,
long leftPositionInFile,
long rightPositionInFile,
boolean colorSetted,
boolean color,
int numberOfChild) |
Modifier and Type | Method and Description |
---|---|
void |
accept(IRBTVisitor<E> visitor)
accept red black tree visitor
|
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 |
HeapRecord |
getHeapRecord() |
int |
getIndex() |
IRBTNode<E> |
getLeft()
get left child of this node
|
long |
getLeftPositionInFile()
get this node left son node mirroring in heap file position
should be used only by HeapRecord to save it in heap file |
int |
getNumberOfChild()
get the number of node in right and left tree node, sentinel excluded
|
IRBTNode<E> |
getParent()
get parent node
|
long |
getParentPositionInFile()
get this node parent node mirroring in heap file position
should be used only by HeapRecord to save it in heap file |
long |
getPositionInFile()
get this node mirroring in heap file position
should be used only by heap red black tree node manager ( specialization of AbstractHeapNodeManager ) and this |
IRBTNode<E> |
getRight()
get right child of this node
|
long |
getRightPositionInFile()
get this node right son node mirroring in heap file position
should be used only by HeapRecord to save it in heap file |
int |
hashCode() |
protected abstract AbstractHeapRBTNode<E> |
heapNode(HeapRecord heapRecord)
get the heap node from the heap record from heap file, depending of heap
tree it is not at same location on heap record.
|
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
|
boolean |
isValueChanged()
to know if state of this changed
|
void |
setBlack()
set node color to black
|
void |
setColor(boolean color)
set node color
color definition: RedBlackTree#BLACK and RedBlackTree#RED |
void |
setIndex(int index) |
void |
setLeft(IRBTNode<E> node)
set left child of this node
|
void |
setLeftPositionInFile(long leftPositionInFile)
set this node left son node mirroring in heap file position
should be used only by HeapRecord to load it from heap file |
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 |
setParentPositionInFile(long parentFilePosition)
set this node parent node mirroring in heap file position
should be used only by HeapRecord to load it from heap file |
void |
setRed()
set node color to red
|
void |
setRight(IRBTNode<E> node)
set right child of this node
|
void |
setRightPositionInFile(long rightPositionInFile)
set this node right son node mirroring in heap file position
should be used only by HeapRecord to load it from heap file |
String |
toString() |
void |
valueSetted() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getElement, setElement
compareTo, compareTo
public boolean valueChanged
public long parentPositionInFile
public long leftPositionInFile
public long rightPositionInFile
public boolean colorSetted
public boolean color
RedBlackTree.BLACK
or RedBlackTree.RED
.
public is bad smell but this done for optimizationpublic int numberOfChild
public int index
protected IHeapElementManager heapElementManager
HeapRecord
, null for sentinel
nodepublic AbstractHeapRBTNode(IHeapElementManager heapElementManager, long positionInFile, long parentPositionInFile, long leftPositionInFile, long rightPositionInFile, boolean colorSetted, boolean color, int numberOfChild)
public HeapRecord getHeapRecord() throws HeapException
HeapException
public long getPositionInFile()
AbstractHeapNodeManager
) and thispublic long getLeftPositionInFile() throws RBTException
HeapRecord
to save it in heap fileRBTException
public long getRightPositionInFile() throws RBTException
HeapRecord
to save it in heap fileRBTException
public long getParentPositionInFile()
HeapRecord
to save it in heap filepublic void setLeftPositionInFile(long leftPositionInFile) throws RBTException
HeapRecord
to load it from heap fileleftPositionInFile
- the position of this node left son node mirroring in heap fileRBTException
public void setRightPositionInFile(long rightPositionInFile) throws RBTException
HeapRecord
to load it from heap fileleftPositionInFile
- the position of this node right son node mirroring in heap
fileRBTException
public void setParentPositionInFile(long parentFilePosition)
HeapRecord
to load it from heap fileleftPositionInFile
- the position of this node parent node mirroring in heap filepublic void setParent(IRBTNode<E> node) throws RBTException
IRBTNode
setParent
in interface IRBTNode<E extends Comparable<E>>
node
- the parent nodeRBTException
- node access errorpublic void setLeft(IRBTNode<E> node) throws RBTException
IRBTNode
setLeft
in interface IRBTNode<E extends Comparable<E>>
node
- the left child of this nodeRBTException
- node access errorpublic void setRight(IRBTNode<E> node) throws RBTException
IRBTNode
setRight
in interface IRBTNode<E extends Comparable<E>>
node
- the right child of this nodeRBTException
- node access errorpublic IRBTNode<E> getParent() throws RBTException
IRBTNode
getParent
in interface IRBTNode<E extends Comparable<E>>
RBTException
- node access errorpublic IRBTNode<E> getLeft() throws RBTException
IRBTNode
getLeft
in interface IRBTNode<E extends Comparable<E>>
RBTException
- node access errorpublic IRBTNode<E> getRight() throws RBTException
IRBTNode
getRight
in interface IRBTNode<E extends Comparable<E>>
RBTException
- node access errorprotected abstract AbstractHeapRBTNode<E> heapNode(HeapRecord heapRecord) throws RBTException
heapRecord
- the heap recordRBTException
public boolean isSentinel()
IRBTNode
isSentinel
in interface IRBTNode<E extends Comparable<E>>
public boolean isColorSetted()
isColorSetted
in interface IRBTNode<E extends Comparable<E>>
public boolean isBlack() throws RBTException
IRBTNode
isBlack
in interface IRBTNode<E extends Comparable<E>>
RBTException
- node access errorpublic boolean isRed() throws RBTException
IRBTNode
isRed
in interface IRBTNode<E extends Comparable<E>>
RBTException
- node access errorpublic void setBlack() throws RBTException
IRBTNode
setBlack
in interface IRBTNode<E extends Comparable<E>>
RBTException
public void setRed() throws RBTException
IRBTNode
setRed
in interface IRBTNode<E extends Comparable<E>>
RBTException
- node access errorpublic void setColor(boolean color) throws RBTException
IRBTNode
RedBlackTree#BLACK
and RedBlackTree#RED
setColor
in interface IRBTNode<E extends Comparable<E>>
color
- the node colorRBTException
- node access errorpublic boolean getColor() throws RBTException
IRBTNode
RedBlackTree#BLACK
and RedBlackTree#RED
getColor
in interface IRBTNode<E extends Comparable<E>>
RBTException
- node access errorpublic int getNumberOfChild() throws RBTException
IRBTNode
getNumberOfChild
in interface IRBTNode<E extends Comparable<E>>
RBTException
- node access errorpublic void setNumberOfChild(int numberOfChild) throws RBTException
IRBTNode
setNumberOfChild
in interface IRBTNode<E extends Comparable<E>>
numberOfChild
- the number of childrenRBTException
public void setIndex(int index)
setIndex
in interface IRBTNode<E extends Comparable<E>>
public int getIndex()
getIndex
in interface IRBTNode<E extends Comparable<E>>
public void decrementNumberOfChild() throws RBTException
decrementNumberOfChild
in interface IRBTNode<E extends Comparable<E>>
RBTException
public void incrementNumberOfChild() throws RBTException
incrementNumberOfChild
in interface IRBTNode<E extends Comparable<E>>
RBTException
public void accept(IRBTVisitor<E> visitor) throws RBTException
IRBTVisitable
accept
in interface IRBTVisitable<E extends Comparable<E>>
visitor
- the red black tree visitorRBTException
- node access errorpublic boolean isValueChanged() throws RBTException
RBTException
public void valueSetted() throws RBTException
RBTException
public void detach()
IRBTNode
detach
in interface IRBTNode<E extends Comparable<E>>
public boolean isAttached()
isAttached
in interface IRBTNode<E extends Comparable<E>>
Copyright © 2007-2012 Luc Peuvrier. All Rights Reserved.