Class TreeNode<T>


  • public class TreeNode<T>
    extends Object
    a simple representation of a tree node
    Since:
    25.03.2022
    Author:
    Pascal Knueppel
    • Constructor Detail

      • TreeNode

        protected TreeNode​(GenericTree<T> tree,
                           T value)
    • Method Detail

      • isRoot

        public boolean isRoot()
        if this node is a root-node or not
      • isLeaf

        public boolean isLeaf()
        if this node is a leaf or not
      • addParents

        public void addParents​(TreeNode<T>... parents)
        add several parents at once
      • addParent

        public void addParent​(TreeNode<T> parent)
        add a parent to this node
      • removeParents

        public void removeParents​(TreeNode<T>... parents)
        removes several parents at once
      • removeParent

        public void removeParent​(TreeNode<T> parent)
        remove a parent from this node
      • addChildren

        public void addChildren​(TreeNode<T>... children)
        adds several children at once
      • addChild

        public void addChild​(TreeNode<T> child)
        add a child to this node
      • removeChildren

        public void removeChildren​(TreeNode<T>... children)
        removes several children at once
      • removeChild

        public void removeChild​(TreeNode<T> child)
        remove a child from this node. If this child has many parents it will not be removed from the tree though
      • getAllBranchNodes

        public Set<TreeNode<T>> getAllBranchNodes()
        Returns:
        the nodes from the whole branch of this node
      • clearParents

        public void clearParents()
        removes this node from its parents and forgets its own parents
      • getValue

        public T getValue()
        this node itself