Class TreeX<T>


  • public class TreeX<T>
    extends java.lang.Object
    • Constructor Detail

      • TreeX

        public TreeX​(java.util.List<TreeX<T>> parents,
                     T value,
                     java.util.List<TreeX<T>> childrenlist)
        create tree node with many parents and many children
      • TreeX

        public TreeX​(TreeX<T> root)
        Copy constructor
      • TreeX

        public TreeX​(TreeX<T> parent,
                     T value,
                     java.util.List<TreeX<T>> childrenlist)
        create tree node with a single parent and many children
      • TreeX

        public TreeX​(java.util.List<TreeX<T>> parents,
                     T value,
                     TreeX<T> child)
        create tree node with many parents and a single child
      • TreeX

        public TreeX​(T value)
        Create a tree node with the given value with a null parents and children
      • TreeX

        public TreeX()
        Create an empty tree node
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
      • getChildren

        public java.util.List<TreeX<T>> getChildren()
        Returns:
        the children
      • setChildren

        public void setChildren​(java.util.List<TreeX<T>> children)
        Parameters:
        children -
      • getLeaves

        public java.util.Set<TreeX<T>> getLeaves()
        returns tree leaves
      • addChild

        public TreeX<T> addChild​(TreeX<T> child)
        Add child node to the current tree node
      • addParent

        public TreeX<T> addParent​(TreeX<T> parent)
        Add parent node to the current tree node
        Returns:
        the added parent node
      • removeChild

        public void removeChild​(TreeX<T> child)
        Remove Child
      • getParent

        public TreeX<T> getParent()
        Return the first parent
      • setParent

        public void setParent​(TreeX<T> parent)
        Parameters:
        parent -
      • getParents

        public java.util.List<TreeX<T>> getParents()
        Return all parents
      • setParents

        public void setParents​(java.util.List<TreeX<T>> parents)
        Parameters:
        parents -
      • getchildren

        public java.util.List<TreeX<T>> getchildren()
        Returns:
        a list of all children nodes of the current tree node
      • getValue

        public T getValue()
        Returns:
        the data value of the current tree node
      • print

        public void print()
        Print current tree in console
      • size

        public long size()
        Returns:
        tree size
      • depth

        public long depth()
        Returns:
        tree depth
      • level

        public long level()
        Returns:
        current node level