Class Tree.Empty<E>

  • Type Parameters:
    E - the element type (used in type inference)
    All Implemented Interfaces:
    Serializable
    Enclosing class:
    Tree<E>

    public static class Tree.Empty<E>
    extends Tree<E>
    Class for the empty tree.
    See Also:
    Serialized Form
    • Constructor Detail

      • Empty

        private Empty()
        Constructor
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Returns true as this represents the empty tree.
        Specified by:
        isEmpty in class Tree<E>
        Returns:
        true
      • leftExists

        public boolean leftExists()
        Returns false as the empty tree does not have a left subtree.
        Specified by:
        leftExists in class Tree<E>
        Returns:
        false
      • rightExists

        public boolean rightExists()
        Returns false as the empty tree does not have a right subtree.
        Specified by:
        rightExists in class Tree<E>
        Returns:
        false
      • toString

        public String toString()
        Returns an empty string as string representation of the empty tree.
        Overrides:
        toString in class Object
        Returns:
        the empty string