java.lang.Object
org.jhotdraw8.icollection.impl.redblack.Empty<K,V>
Type Parameters:
K - Component type
All Implemented Interfaces:
Iterable<Node<K,V>>, RedBlackTree<K,V>

public final class Empty<K,V> extends Object implements RedBlackTree<K,V>
The empty tree node.

This class has been derived from 'vavr' RedBlackTree.java.

RedBlackTree.java. Copyright 2023 (c) vavr. MIT License.
github.com
  • Field Details

    • EMPTY

      public static final Empty<?,?> EMPTY
  • Method Details

    • empty

      public static <K, V> Empty<K,V> empty()
    • color

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

      An empty node is BLACK by definition.

      Specified by:
      color in interface RedBlackTree<K,V>
      Returns:
      Either RED or BLACK.
    • contains

      public boolean contains(K key, Comparator<? super K> comparator)
      Description copied from interface: RedBlackTree
      Checks, if this RedBlackTree contains the given key.
      Specified by:
      contains in interface RedBlackTree<K,V>
      Parameters:
      key - A key.
      comparator -
      Returns:
      true, if this tree contains the value, false otherwise.
    • find

      public RedBlackTree<K,V> find(K key, Comparator<? super K> comparator)
      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<K,V>
      Parameters:
      key - A value
      comparator -
      Returns:
      Some value, if this tree contains a value equal to the given value according to the underlying comparator. Otherwise None.
    • ceiling

      public @NonNull RedBlackTree<K,V> ceiling(K e, @NonNull Comparator<? super K> comparator)
      Description copied from interface: RedBlackTree
      Returns the least Node in this tree greater than or equal to the given element, or Empty if there is no such element.
      Specified by:
      ceiling in interface RedBlackTree<K,V>
    • floor

      public @NonNull RedBlackTree<K,V> floor(K e, @NonNull Comparator<? super K> comparator)
      Description copied from interface: RedBlackTree
      Returns the greatest Node in this tree less than or equal to the given element, or Empty if there is no such element.
      Specified by:
      floor in interface RedBlackTree<K,V>
    • higher

      public @NonNull RedBlackTree<K,V> higher(K e, @NonNull Comparator<? super K> comparator)
      Description copied from interface: RedBlackTree
      Returns the least Node in this tree strictly greater than the given element, or Empty if there is no such element.
      Specified by:
      higher in interface RedBlackTree<K,V>
    • orElse

      public RedBlackTree<K,V> orElse(RedBlackTree<K,V> other)
      Description copied from interface: RedBlackTree
      Returns this RedBlackTree if it is nonempty, otherwise return the alternative.
      Specified by:
      orElse in interface RedBlackTree<K,V>
    • lower

      public @NonNull RedBlackTree<K,V> lower(K e, @NonNull Comparator<? super K> comparator)
      Description copied from interface: RedBlackTree
      Returns the greatest Node in this tree strictly less than the given element, or Empty if there is no such element.
      Specified by:
      lower in interface RedBlackTree<K,V>
    • 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<K,V>
      Returns:
      true, if it is empty, false otherwise.
    • left

      public RedBlackTree<K,V> 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<K,V>
      Returns:
      The left child.
    • right

      public @NonNull RedBlackTree<K,V> 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<K,V>
      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<K,V>
      Returns:
      the number of nodes of this tree and 0 if this is the empty tree
    • getKey

      public K getKey()
      Description copied from interface: RedBlackTree
      Returns the key of the current tree node or throws if this is empty.
      Specified by:
      getKey in interface RedBlackTree<K,V>
      Returns:
      The value.
    • getValue

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

      public @Nullable K keyOrNull()
      Description copied from interface: RedBlackTree
      Returns the key of this RedBlackTree or null if it is empty.
      Specified by:
      keyOrNull in interface RedBlackTree<K,V>
    • valueOrNull

      public @Nullable V valueOrNull()
      Description copied from interface: RedBlackTree
      Returns the value of this RedBlackTree or null if it is empty.
      Specified by:
      valueOrNull in interface RedBlackTree<K,V>
    • mapOrNull

      public <E> @Nullable E mapOrNull(@NonNull BiFunction<K,V,E> f)
      Specified by:
      mapOrNull in interface RedBlackTree<K,V>
    • entryOrNull

      public @Nullable Map.Entry<K,V> entryOrNull()
      Description copied from interface: RedBlackTree
      Returns the map entry of this RedBlackTree or null if it is empty.
      Specified by:
      entryOrNull in interface RedBlackTree<K,V>
    • isRed

      public boolean isRed()
      Specified by:
      isRed in interface RedBlackTree<K,V>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toLispString

      public String toLispString()
      Specified by:
      toLispString in interface RedBlackTree<K,V>