Module org.dyn4j
Package org.dyn4j

Class BinarySearchTreeNode<E extends java.lang.Comparable<E>>

  • Type Parameters:
    E - the comparable type
    All Implemented Interfaces:
    java.lang.Comparable<BinarySearchTreeNode<E>>

    final class BinarySearchTreeNode<E extends java.lang.Comparable<E>>
    extends java.lang.Object
    implements java.lang.Comparable<BinarySearchTreeNode<E>>
    Node class for the BinarySearchTree.
    Since:
    2.2.0
    Version:
    3.1.9
    Author:
    William Bittle
    • Field Detail

      • comparable

        final E extends java.lang.Comparable<E> comparable
        The comparable data
      • left

        BinarySearchTreeNode<E extends java.lang.Comparable<E>> left
        The node to the left; the left node is greater than this node
      • right

        BinarySearchTreeNode<E extends java.lang.Comparable<E>> right
        The node to the right; the right node is greater than this node
    • Constructor Detail

      • BinarySearchTreeNode

        public BinarySearchTreeNode​(E comparable)
        Minimal constructor.
        Parameters:
        comparable - the comparable object
      • BinarySearchTreeNode

        public BinarySearchTreeNode​(E comparable,
                                    BinarySearchTreeNode<E> parent,
                                    BinarySearchTreeNode<E> left,
                                    BinarySearchTreeNode<E> right)
        Full constructor.
        Parameters:
        comparable - the comparable object
        parent - the parent node
        left - the left node
        right - the right node
        Throws:
        java.lang.NullPointerException - if comparable is null
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • compareTo

        public int compareTo​(BinarySearchTreeNode<E> other)
        Specified by:
        compareTo in interface java.lang.Comparable<E extends java.lang.Comparable<E>>
      • getComparable

        public E getComparable()
        Returns the comparable object.
        Returns:
        E
      • isLeftChild

        boolean isLeftChild()
        Returns true if this node is the left child of its parent node.

        Returns false if this node does not have a parent.

        Returns:
        boolean