public abstract class AbstractTargetTree<E> extends java.lang.Object implements TargetTree
Modifier and Type | Field and Description |
---|---|
protected int |
bufferSize |
protected E |
data |
protected int[] |
descendantCounts |
protected int |
edgePointer |
protected int[][] |
edges |
protected int[] |
heads |
protected int[] |
heights |
protected static int |
LIST_START_SIZE |
protected boolean[][] |
locks |
protected int |
nodePointer |
protected int |
rootCount |
protected java.util.List<java.lang.Integer> |
roots |
protected int |
size |
Modifier | Constructor and Description |
---|---|
protected |
AbstractTargetTree() |
Modifier and Type | Method and Description |
---|---|
protected void |
buildBuffer() |
void |
close()
Releases all internal data structures
|
protected abstract int |
fetchHead(int index) |
protected abstract int |
fetchSize() |
int |
getChildIndexAt(int nodeIndex,
int index) |
int |
getDescendantCount()
Returns the number of nodes in the sub-tree whose root the node currently
being viewed is.
|
int |
getEdgeCount()
Returns the number of outgoing edges on the currently viewed
node.
|
int |
getEdgeIndex()
Returns the index of the edge currently being viewed or
-1 if the current scope is not pointed on an edge. |
int |
getHeight()
Returns the height of the sub-tree whose root node is the node currently
being viewed.
|
int |
getNodeIndex()
Returns the index of the node currently being viewed or
-1 if the current scope is not pointed on a node. |
int |
getParentIndex()
Returns the index of the current node's parent node or
-1
if the current node is the root node. |
E |
getSource() |
int |
getSourceIndex()
Returns the index of the source node of the currently viewed edge.
|
int |
getTargetIndex()
Returns the index of the target node of the currently viewed edge.
|
boolean |
isEdgeLocked() |
boolean |
isEdgeLocked(int index) |
boolean |
isEdgeLocked(int nodeIndex,
int index) |
boolean |
isNodeLocked() |
boolean |
isNodeLocked(int index) |
boolean |
isRoot() |
void |
lockEdge() |
void |
lockEdge(int index) |
void |
lockEdge(int nodeIndex,
int index) |
void |
lockNode() |
void |
lockNode(int index) |
protected void |
prepare(de.ims.icarus.util.Options options) |
protected void |
prepareDescendants0(int index) |
void |
reload(java.lang.Object source,
de.ims.icarus.util.Options options)
Rebuild the graph representation based on the given data input.
|
void |
reset()
Clears any pointer structures and unlocks all locking flags
|
int |
size()
Returns the number of nodes (vertices) in the tree
|
protected abstract boolean |
supports(java.lang.Object data) |
void |
unlockAll() |
void |
unlockChildren(int index) |
void |
unlockEdge() |
void |
unlockEdge(int index) |
void |
unlockEdge(int nodeIndex,
int index) |
void |
unlockNode() |
void |
unlockNode(int index) |
void |
viewChild(int index) |
void |
viewEdge(int index)
Moves the scope to the edge at position
index of the
current node. |
void |
viewEdge(int nodeIndex,
int edgeIndex)
Moves the scope to the edge at position
index of the
node specified by nodeIndex . |
void |
viewNode(int index)
Moves the scope to the node at position
index in the graph. |
void |
viewParent()
Moves the scope to the node that is the parent of the current node.
|
void |
viewSource() |
void |
viewTarget() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDirection, getDistance, getProperty
protected int[][] edges
protected boolean[][] locks
protected int[] heights
protected int[] descendantCounts
protected java.util.List<java.lang.Integer> roots
protected int rootCount
protected int[] heads
protected int size
protected E data
protected int nodePointer
protected int edgePointer
protected int bufferSize
protected static final int LIST_START_SIZE
protected void buildBuffer()
public void close()
TargetTree
close
in interface TargetTree
public int size()
TargetTree
size
in interface TargetTree
TargetTree.size()
public void reset()
TargetTree
reset
in interface TargetTree
TargetTree.reset()
public E getSource()
getSource
in interface TargetTree
protected abstract int fetchSize()
protected abstract int fetchHead(int index)
protected void prepare(de.ims.icarus.util.Options options)
protected abstract boolean supports(java.lang.Object data)
public void reload(java.lang.Object source, de.ims.icarus.util.Options options)
TargetTree
reload
in interface TargetTree
de.ims.icarus.search_tools.tree.TargetTree#reload(java.lang.Object)
protected void prepareDescendants0(int index)
public int getNodeIndex()
TargetTree
-1
if the current scope is not pointed on a node.getNodeIndex
in interface TargetTree
TargetTree.getNodeIndex()
public int getEdgeIndex()
TargetTree
-1
if the current scope is not pointed on an edge.getEdgeIndex
in interface TargetTree
TargetTree.getEdgeIndex()
public int getEdgeCount()
TargetTree
getEdgeCount
in interface TargetTree
TargetTree.getEdgeCount()
public void viewEdge(int index)
TargetTree
index
of the
current node.
Precondition: #getNodeIndex()
!=-1 && #getEdgeIndex()
==-1
Postcondition: #getEdgeIndex()
==index && #getNodeIndex()
==-1
viewEdge
in interface TargetTree
TargetTree.viewEdge(int)
public void viewEdge(int nodeIndex, int edgeIndex)
TargetTree
index
of the
node specified by nodeIndex
.
Postcondition: #getEdgeIndex()
==edgeIndex && #getNodeIndex()
==-1
viewEdge
in interface TargetTree
TargetTree.viewEdge(int, int)
public int getSourceIndex()
TargetTree
getSourceIndex
in interface TargetTree
TargetTree.getSourceIndex()
public int getTargetIndex()
TargetTree
getTargetIndex
in interface TargetTree
TargetTree.getTargetIndex()
public boolean isRoot()
isRoot
in interface TargetTree
public int getParentIndex()
TargetTree
-1
if the current node is the root node.getParentIndex
in interface TargetTree
TargetTree.getParentIndex()
public void viewNode(int index)
TargetTree
index
in the graph.
Precondition: #getNodeIndex()
!=-1 && #getEdgeIndex()
==-1
Postcondition: #getEdgeIndex()
==index && #getNodeIndex()
==-1
viewNode
in interface TargetTree
TargetTree.viewNode(int)
public void viewChild(int index)
viewChild
in interface TargetTree
TargetTree.viewChild(int)
public int getChildIndexAt(int nodeIndex, int index)
getChildIndexAt
in interface TargetTree
TargetTree.getChildIndexAt(int, int)
public void viewParent()
TargetTree
Precondition: #getNodeIndex()
!=-1 && #getEdgeIndex()
==-1 && i
==#getParentIndex()
Postcondition: #getEdgeIndex()
==-1 && #getNodeIndex()
==i
viewParent
in interface TargetTree
TargetTree.viewParent()
public void viewTarget()
viewTarget
in interface TargetTree
TargetTree.viewTarget()
public void viewSource()
viewSource
in interface TargetTree
TargetTree.viewSource()
public int getHeight()
TargetTree
1
and for any
other node it is 1
plus the maximum of any of its child nodes height.getHeight
in interface TargetTree
TargetTree.getHeight()
public int getDescendantCount()
TargetTree
0
for leaf nodes.getDescendantCount
in interface TargetTree
TargetTree.getDescendantCount()
public void lockNode()
lockNode
in interface TargetTree
TargetTree.lockNode()
public void lockEdge()
lockEdge
in interface TargetTree
TargetTree.lockEdge()
public void lockEdge(int index)
lockEdge
in interface TargetTree
TargetTree.lockEdge(int)
public void lockEdge(int nodeIndex, int index)
lockEdge
in interface TargetTree
TargetTree.lockEdge(int, int)
public void lockNode(int index)
lockNode
in interface TargetTree
TargetTree.lockNode(int)
public void unlockNode()
unlockNode
in interface TargetTree
TargetTree.unlockNode()
public void unlockEdge()
unlockEdge
in interface TargetTree
TargetTree.unlockEdge()
public void unlockEdge(int index)
unlockEdge
in interface TargetTree
TargetTree.unlockEdge(int)
public void unlockEdge(int nodeIndex, int index)
unlockEdge
in interface TargetTree
TargetTree.unlockEdge(int, int)
public void unlockNode(int index)
unlockNode
in interface TargetTree
TargetTree.unlockNode(int)
public void unlockChildren(int index)
unlockChildren
in interface TargetTree
TargetTree.unlockChildren(int)
public boolean isNodeLocked()
isNodeLocked
in interface TargetTree
TargetTree.isNodeLocked()
public boolean isEdgeLocked()
isEdgeLocked
in interface TargetTree
TargetTree.isEdgeLocked()
public boolean isNodeLocked(int index)
isNodeLocked
in interface TargetTree
TargetTree.isNodeLocked(int)
public boolean isEdgeLocked(int index)
isEdgeLocked
in interface TargetTree
TargetTree.isEdgeLocked(int)
public boolean isEdgeLocked(int nodeIndex, int index)
isEdgeLocked
in interface TargetTree
TargetTree.isEdgeLocked(int, int)
public void unlockAll()
unlockAll
in interface TargetTree
TargetTree.unlockAll()