lv.lumii.layoutengine.flowLayout.horizontalOrdering.pqtree

## Class PQTree<T>

- java.lang.Object
- - lv.lumii.layoutengine.flowLayout.horizontalOrdering.pqtree.PQTree<T>

- Type Parameters:
    `T` - object type

      public class PQTree<T>
      extends java.lang.Object

  This class implements PQTree data structure.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `CNODE`
    `static int` | `PNODE`
    `static int` | `QNODE`
    `PQTreeNode<T>` | `root`
    `PQTreeNode` | `testNode`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PQTree()`
    `PQTree(java.util.Collection<? extends T> U)` This is constructor of pq-tree that creates initial pq-tree.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### testNode

          public PQTreeNode testNode

    - #### root

          public PQTreeNode<T> root

    - #### PNODE

          public static final int PNODE

      See Also:
        Constant Field Values

    - #### QNODE

          public static final int QNODE

      See Also:
        Constant Field Values

    - #### CNODE

          public static final int CNODE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PQTree

          public PQTree()

    - #### PQTree

          public PQTree(java.util.Collection<? extends T> U)

      This is constructor of pq-tree that creates initial pq-tree.
      Parameters:
        `U` - collection of objects that need to be in pq-tree.

  - ### Method Detail

    - #### copy

          public void copy(PQTree<T> sourceObject)

      Method that copies pq-tree structure from another pq-tree.
      Parameters:
        `sourceObject` - source pq-tree from which structure is copied.

    - #### setInvisibleNodeSet

          public void setInvisibleNodeSet(java.util.Set<T> s)

      This method sets invisible node set.
      Parameters:
        `s` - set of objects that are invisible.

    - #### isInvisibleNode

          public boolean isInvisibleNode(PQTreeNode<T> node)

      This method returns whether this node is invisible.
      Parameters:
        `node` - node to be tested for being invisible.
      Returns:
        `true` if this is invisible node, `false` otherwise.

    - #### setHangingNodeSet

          public void setHangingNodeSet(java.util.Set<T> hangingNodeSet)

    - #### isHangingNode

          public boolean isHangingNode(CNode node)

      This method returns whether this node is hanging.
      Parameters:
        `node` - node to be tested for being hanging.
      Returns:
        `true` if this is hanging node, `false` otherwise.

    - #### getObjects

          public java.util.List<T> getObjects()

    - #### setLLValue

          public void setLLValue(int llValue)

    - #### getLLValue

          public int getLLValue()

    - #### getUserObject

          public java.util.Collection<T> getUserObject()

    - #### setUserObject

          public void setUserObject(java.util.Collection<T> userObject)

    - #### isUserObjectInUse

          public boolean isUserObjectInUse()

    - #### clearUserObject

          public void clearUserObject()

    - #### getList

          public java.util.LinkedList<T> getList(java.util.List<? extends java.util.Set<T>> sequenceRulesList)

      This method returns possible permutation of objects in pq-tree.
      Parameters:
        `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.
      Returns:
        list of objects that are in valid order.

    - #### addRule

          public boolean addRule(java.util.Collection<T> ruleObjectSet)

      This method adds rule to pq-tree that some set of objects needs to be together.
      Parameters:
        `ruleObjectSet` - objects that needs to be together.
      Returns:
        boolean value whether this rule was feasible.

    - #### updateLevelInfo

          public void updateLevelInfo()

      This method updates level information in each PQ-tree node. This is used with priority queue to traverse tree correctly.

    - #### cleanUp

          public void cleanUp()

      This node removes all full signs all nodes. This is necessary after every new addRule operation.

    - #### seal

          public void seal()

      This method finishes pq-tree - removes unnecessary nodes from pq-tree - those with one child.

    - #### normalize

          public void normalize()

      This method normalizes PQ-tree:
      - replaces all p-nodes with two children with q-node
      - removes all nodes with just one child.

    - #### removeUnnecessary

          public void removeUnnecessary()

      This method removes all nodes from tree that has only one child node.

    - #### print

          public void print()

      This method prints all pq-tree structure to console.

    - #### replace

          public void replace(T existingObject,
                              T newObject)

      This method replaces one object in c-node connection with another.
      Parameters:
        `existingObject` - object that currently is in pq-tree.
        `newObject` - object that will be inserted in pq-tree in place of existing object.

    - #### replaceList

          public 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.
      Parameters:
        `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.

    - #### remove

          public void remove(java.util.Collection<T> U)

      This method removes all c-nodes that are connected with objects from U.
      Parameters:
        `U` - collection of removable objects.

    - #### addElement

          public void addElement(T o)

      This method adds new element to PQ-tree. Element is added as child of P node. If none of two top vertices are P type then new top two vertices are added to PQ-tree.
      Parameters:
        `o` - new object that will be represented by new c-node.

    - #### insert

          public void insert(PQTree<T> t1,
                             T o,
                             java.util.List<T> allObjects)

      This method implements two PQ-Tree merge operation. This and specified trees are merged together so that they share common object.
      Parameters:
        `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.

    - #### replaceTree

          public void replaceTree(PQTree<T> tree)

      This method replaces all occurrences of this PQ-Tree in its nodes with given tree. This is used when two PQ-Trees are merged together.
      Parameters:
        `tree` - PQ-Tree that will be inserted in place of current tree.

    - #### getChildObjects

          public java.util.Set<T> getChildObjects(PQTreeNode<T> node)

      This method returns all objects that are in subtree of this node.
      Parameters:
        `node` - PQTreeNode which subtree is analyzed.
      Returns:
        Set of objects that belongs to the C nodes below this node.