Class RedBlackTreeModule.Empty<T>

  • Type Parameters:
    T - Component type
    All Implemented Interfaces:
    RedBlackTree<T>, java.io.Serializable, java.lang.Iterable<T>
    Enclosing interface:
    RedBlackTreeModule

    public static final class RedBlackTreeModule.Empty<T>
    extends java.lang.Object
    implements RedBlackTree<T>, java.io.Serializable
    The empty tree node. It can't be a singleton because it depends on a Comparator.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.Comparator<T> comparator  
      private static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
      Empty​(java.util.Comparator<? super T> comparator)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      RedBlackTree.Color color()
      Return the RedBlackTree.Color of this Red/Black Tree node.
      java.util.Comparator<T> comparator()
      Returns the underlying Comparator of this RedBlackTree.
      boolean contains​(T value)
      Checks, if this RedBlackTree contains the given value.
      RedBlackTreeModule.Empty<T> emptyInstance()
      Returns the empty instance of this RedBlackTree.
      Option<T> find​(T value)
      Finds the value stored in this tree, if exists, by applying the underlying comparator to the tree elements and the given element.
      boolean isEmpty()
      Checks if this RedBlackTree is empty, i.e.
      RedBlackTree<T> left()
      Returns the left child if this is a non-empty node, otherwise throws.
      RedBlackTree<T> right()
      Returns the right child if this is a non-empty node, otherwise throws.
      int size()
      Returns the size of this tree.
      java.lang.String toString()
      Returns a Lisp like representation of this tree.
      T value()
      Returns the value of the current tree node or throws if this is empty.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • comparator

        final java.util.Comparator<T> comparator
    • Constructor Detail

      • Empty

        Empty​(java.util.Comparator<? super T> comparator)
    • Method Detail

      • comparator

        public java.util.Comparator<T> comparator()
        Description copied from interface: RedBlackTree
        Returns the underlying Comparator of this RedBlackTree.
        Specified by:
        comparator in interface RedBlackTree<T>
        Returns:
        The comparator.
      • contains

        public boolean contains​(T value)
        Description copied from interface: RedBlackTree
        Checks, if this RedBlackTree contains the given value.
        Specified by:
        contains in interface RedBlackTree<T>
        Parameters:
        value - A value.
        Returns:
        true, if this tree contains the value, false otherwise.
      • find

        public Option<T> find​(T value)
        Description copied from interface: RedBlackTree
        Finds the value stored in this tree, if exists, by applying the underlying comparator to the tree elements and the given element.

        Especially the value returned may differ from the given value, even if the underlying comparator states that both are equal.

        Specified by:
        find in interface RedBlackTree<T>
        Parameters:
        value - A value
        Returns:
        Some value, if this tree contains a value equal to the given value according to the underlying comparator. Otherwise None.
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: RedBlackTree
        Checks if this RedBlackTree is empty, i.e. an instance of Leaf.
        Specified by:
        isEmpty in interface RedBlackTree<T>
        Returns:
        true, if it is empty, false otherwise.
      • left

        public RedBlackTree<T> left()
        Description copied from interface: RedBlackTree
        Returns the left child if this is a non-empty node, otherwise throws.
        Specified by:
        left in interface RedBlackTree<T>
        Returns:
        The left child.
      • right

        public RedBlackTree<T> right()
        Description copied from interface: RedBlackTree
        Returns the right child if this is a non-empty node, otherwise throws.
        Specified by:
        right in interface RedBlackTree<T>
        Returns:
        The right child.
      • size

        public int size()
        Description copied from interface: RedBlackTree
        Returns the size of this tree.
        Specified by:
        size in interface RedBlackTree<T>
        Returns:
        the number of nodes of this tree and 0 if this is the empty tree
      • value

        public T value()
        Description copied from interface: RedBlackTree
        Returns the value of the current tree node or throws if this is empty.
        Specified by:
        value in interface RedBlackTree<T>
        Returns:
        The value.
      • toString

        public java.lang.String toString()
        Description copied from interface: RedBlackTree
        Returns a Lisp like representation of this tree.
        Specified by:
        toString in interface RedBlackTree<T>
        Overrides:
        toString in class java.lang.Object
        Returns:
        This Tree as Lisp like String.