Interface Tree<T>

  • Type Parameters:
    T - The type of data contained in the tree
    All Known Implementing Classes:
    BinarySearchTree, BinaryTree, GeneralTree

    public interface Tree<T>
    A tree for organising data.
    • Method Detail

      • contains

        boolean contains​(T object)
        Check if the tree contains the given data somewhere.
        Parameters:
        object - The object
        Returns:
        Is it in the tree?
      • depthStream

        Stream<T> depthStream()
        Return a stream that does depth-first traversal of the tree.
        Returns:
        The stream
      • breadthStream

        Stream<T> breadthStream()
        Return a stream that does breadth-first traversal of the tree.
        Returns:
        The stream
      • getRoot

        T getRoot()
        Return the data at the root of the tree
        Returns:
        The data
      • getDepth

        int getDepth()
        Return the depth of the tree.
        Returns:
        The depth
      • getWidth

        int getWidth()
        Return the width of the tree
        Returns:
      • getParent

        Optional<T> getParent​(T child)
        Get the parent data for child data
        Parameters:
        child - The child data
        Returns:
        The parent data