Class GenericTree<T>

java.lang.Object
de.captaingoldfish.scim.sdk.common.tree.GenericTree<T>

public class GenericTree<T> extends Object
this implementation represents a tree with several root-nodes and each node might have several parents and several children. This tree implementation is not thread-safe!
Since:
25.03.2022
Author:
Pascal Knueppel
  • Constructor Details

    • GenericTree

      public GenericTree()
  • Method Details

    • addNewNode

      public TreeNode<T> addNewNode(T value)
      creates a new tree node with this tree as its parent
      Parameters:
      parents - the parents of the new node. May be null
      value - the actual value of the node
      children - the children of the node. May be null
      Returns:
      a new tree-node that is a child of this tree
    • addLeaf

      protected void addLeaf(TreeNode<T> treeNode)
      method is only called by tree nodes
    • removeLeaf

      protected void removeLeaf(TreeNode<T> treeNode)
    • addRoot

      protected void addRoot(TreeNode<T> treeNode)
    • removeRoot

      protected void removeRoot(TreeNode<T> treeNode)
    • addNode

      protected void addNode(TreeNode<T> treeNode)
    • removeNodeFromTree

      public void removeNodeFromTree(TreeNode<T> treeNode)
      removes a single node from the tree. If the node was somewhere in the middle of the tree we will basically get a second tree because its branch was cut off from the first tree
    • removeBranchFromTree

      public void removeBranchFromTree(TreeNode<T> treeNode)
      removes the branch from the tree represented by the given treenode
      Parameters:
      treeNode - the branch to remove
    • addDistinctNode

      public TreeNode<T> addDistinctNode(T value)
      creates a new node if a node with the same value does not exist yet and returns the existing node if a node with an identical value does already exist
    • hasNodes

      public boolean hasNodes()
      if this tree still has any nodes left
    • getAllNodes

      public Set<TreeNode<T>> getAllNodes()
      See Also:
      • allNodes
    • getRoots

      public Set<TreeNode<T>> getRoots()
      See Also:
      • roots
    • getLeafs

      public Set<TreeNode<T>> getLeafs()
      See Also:
      • leafs