Class RedBlackTreeModule.Empty<T>

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

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

  • Constructor Details

  • Method Details

    • color

      public RedBlackTree.Color color()
      Description copied from interface: RedBlackTree
      Return the RedBlackTree.Color of this Red/Black Tree node.

      An empty node is BLACK by definition.

      Specified by:
      color in interface RedBlackTree<T>
      Returns:
      Either RED or BLACK.
    • comparator

      public 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.
    • emptyInstance

      public RedBlackTreeModule.Empty<T> emptyInstance()
      Description copied from interface: RedBlackTree
      Returns the empty instance of this RedBlackTree.
      Specified by:
      emptyInstance in interface RedBlackTree<T>
      Returns:
      An empty ReadBlackTree
    • 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 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 Object
      Returns:
      This Tree as Lisp like String.