Class LinkedTree<D,​N extends TreeNode<D,​N>>

  • Type Parameters:
    D - is the type of the data inside the tree
    N - is the type of the tree nodes.
    All Implemented Interfaces:
    Serializable, Iterable<N>, BroadFirstIterableTree<D,​N>, DepthFirstIterableTree<D,​N>, Tree<D,​N>

    public class LinkedTree<D,​N extends TreeNode<D,​N>>
    extends AbstractTree<D,​N>
    This is the generic implementation of a tree based on linked lists.

    This tree assumes that the nodes are linked with there references.

    Since:
    13.0
    Version:
    17.0 2020-01-04 14:41:41
    Author:
    Stéphane GALLAND
    See Also:
    Serialized Form
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    mathtree
    • Constructor Detail

      • LinkedTree

        public LinkedTree()
        Create an emtpy tree.
      • LinkedTree

        public LinkedTree​(N root1)
        Create a tree with the given node.
        Parameters:
        root1 - is the root.
    • Method Detail

      • getRoot

        @Pure
        public N getRoot()
        Description copied from interface: Tree
        Replies the root of the tree.
        Returns:
        the root of the tree.
      • setRoot

        public void setRoot​(N newRoot)
        Description copied from interface: Tree
        Set the root of the tree.
        Parameters:
        newRoot - is the new root node.
      • clear

        public void clear()
        Clear the tree.

        Caution: this method also destroyes the links between the nodes inside the tree. If you want to unlink the root node with this tree but leave the nodes' links unchanged, please call setRoot(null).

      • getNodeCount

        @Pure
        public int getNodeCount()
        Description copied from interface: Tree
        Replies the count of nodes inside this tree.
        Returns:
        the count of nodes inside the whole tree.
      • getUserDataCount

        @Pure
        public int getUserDataCount()
        Description copied from interface: Tree
        Replies the count of data inside this tree.
        Returns:
        the count of user objects inside the whole tree.
      • computeUserDataCount

        public int computeUserDataCount()
        Force the computation of the user data count.
        Returns:
        the count of data.
      • getMinHeight

        @Pure
        public int getMinHeight()
        Description copied from interface: Tree
        Replies the minimal height of the tree.
        Returns:
        the height of the uppest leaf in the tree.
      • getMaxHeight

        @Pure
        public int getMaxHeight()
        Description copied from interface: Tree
        Replies the maximal height of the tree.
        Returns:
        the height of the lowest leaf in the tree.
      • getHeights

        @Pure
        public int[] getHeights()
        Description copied from interface: Tree
        Replies the heights of all the leaf nodes. The order of the heights is given by a depth-first iteration.
        Returns:
        the heights of the leaf nodes