T
- object typepublic class PQTree<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
CNODE |
static int |
PNODE |
static int |
QNODE |
PQTreeNode<T> |
root |
PQTreeNode |
testNode |
Constructor and Description |
---|
PQTree() |
PQTree(java.util.Collection<? extends T> U)
This is constructor of pq-tree that creates initial pq-tree.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(T o)
This method adds new element to PQ-tree.
|
boolean |
addRule(java.util.Collection<T> ruleObjectSet)
This method adds rule to pq-tree that some set of objects needs to be
together.
|
void |
cleanUp()
This node removes all full signs all nodes.
|
void |
clearUserObject() |
void |
copy(PQTree<T> sourceObject)
Method that copies pq-tree structure from another pq-tree.
|
java.util.Set<T> |
getChildObjects(PQTreeNode<T> node)
This method returns all objects that are in subtree of this node.
|
java.util.LinkedList<T> |
getList(java.util.List<? extends java.util.Set<T>> sequenceRulesList)
This method returns possible permutation of objects in pq-tree.
|
int |
getLLValue() |
java.util.List<T> |
getObjects() |
java.util.Collection<T> |
getUserObject() |
void |
insert(PQTree<T> t1,
T o,
java.util.List<T> allObjects)
This method implements two PQ-Tree merge operation.
|
boolean |
isHangingNode(CNode node)
This method returns whether this node is hanging.
|
boolean |
isInvisibleNode(PQTreeNode<T> node)
This method returns whether this node is invisible.
|
boolean |
isUserObjectInUse() |
void |
normalize()
This method normalizes PQ-tree:
replaces all p-nodes with two children with q-node
removes all nodes with just one child.
|
void |
print()
This method prints all pq-tree structure to console.
|
void |
remove(java.util.Collection<T> U)
This method removes all c-nodes that are connected with objects from U.
|
void |
removeUnnecessary()
This method removes all nodes from tree that has only one child node.
|
void |
replace(T existingObject,
T newObject)
This method replaces one object in c-node connection with another.
|
void |
replaceList(java.util.LinkedList<T> replaceNodeList,
T newObject)
This method inserts new node in PQ-tree so that it would fit into
place of replaceable node list.
|
void |
replaceTree(PQTree<T> tree)
This method replaces all occurrences of this PQ-Tree in its nodes with
given tree.
|
void |
seal()
This method finishes pq-tree - removes unnecessary nodes from pq-tree -
those with one child.
|
void |
setHangingNodeSet(java.util.Set<T> hangingNodeSet) |
void |
setInvisibleNodeSet(java.util.Set<T> s)
This method sets invisible node set.
|
void |
setLLValue(int llValue) |
void |
setUserObject(java.util.Collection<T> userObject) |
void |
updateLevelInfo()
This method updates level information in each PQ-tree node.
|
public PQTreeNode testNode
public PQTreeNode<T> root
public static final int PNODE
public static final int QNODE
public static final int CNODE
public PQTree()
public PQTree(java.util.Collection<? extends T> U)
U
- collection of objects that need to be in pq-tree.public void copy(PQTree<T> sourceObject)
sourceObject
- source pq-tree from which structure is copied.public void setInvisibleNodeSet(java.util.Set<T> s)
s
- set of objects that are invisible.public boolean isInvisibleNode(PQTreeNode<T> node)
node
- node to be tested for being invisible.true
if this is invisible node, false
otherwise.public void setHangingNodeSet(java.util.Set<T> hangingNodeSet)
public boolean isHangingNode(CNode node)
node
- node to be tested for being hanging.true
if this is hanging node, false
otherwise.public java.util.List<T> getObjects()
public void setLLValue(int llValue)
public int getLLValue()
public java.util.Collection<T> getUserObject()
public void setUserObject(java.util.Collection<T> userObject)
public boolean isUserObjectInUse()
public void clearUserObject()
public java.util.LinkedList<T> getList(java.util.List<? extends java.util.Set<T>> sequenceRulesList)
sequenceRulesList
- list of node sets that restrict that nodes from
set in i-th position should be no further than nodes from i+1-th set.public boolean addRule(java.util.Collection<T> ruleObjectSet)
ruleObjectSet
- objects that needs to be together.public void updateLevelInfo()
public void cleanUp()
public void seal()
public void normalize()
public void removeUnnecessary()
public void print()
public void replace(T existingObject, T newObject)
existingObject
- object that currently is in pq-tree.newObject
- object that will be inserted in pq-tree in place of
existing object.public void replaceList(java.util.LinkedList<T> replaceNodeList, T newObject)
replaceNodeList
- list of objects that represents list of nodes
from previous level which to replace with new object.newObject
- new object that will be placed in place of
replaceable objects.public void remove(java.util.Collection<T> U)
U
- collection of removable objects.public void addElement(T o)
o
- new object that will be represented by new c-node.public void insert(PQTree<T> t1, T o, java.util.List<T> allObjects)
t1
- specified PQ-Tree that will be merged into this tree.o
- object that is common for both trees.allObjects
- List of all objects to whom t1 is merged.public void replaceTree(PQTree<T> tree)
tree
- PQ-Tree that will be inserted in place of current tree.public java.util.Set<T> getChildObjects(PQTreeNode<T> node)
node
- PQTreeNode which subtree is analyzed.