Package io.vavr.collection
Class RedBlackTreeModule.Empty<T>
- java.lang.Object
-
- io.vavr.collection.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 aComparator.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.vavr.collection.RedBlackTree
RedBlackTree.Color
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Comparator<T>comparatorprivate static longserialVersionUID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RedBlackTree.Colorcolor()Return theRedBlackTree.Colorof this Red/Black Tree node.java.util.Comparator<T>comparator()Returns the underlyingComparatorof this RedBlackTree.booleancontains(T value)Checks, if thisRedBlackTreecontains the givenvalue.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.booleanisEmpty()Checks if thisRedBlackTreeis 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.intsize()Returns the size of this tree.java.lang.StringtoString()Returns a Lisp like representation of this tree.Tvalue()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 io.vavr.collection.RedBlackTree
delete, difference, insert, intersection, iterator, max, min, union
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
comparator
final java.util.Comparator<T> comparator
-
-
Constructor Detail
-
Empty
Empty(java.util.Comparator<? super T> comparator)
-
-
Method Detail
-
color
public RedBlackTree.Color color()
Description copied from interface:RedBlackTreeReturn theRedBlackTree.Colorof this Red/Black Tree node.An empty node is
BLACKby definition.- Specified by:
colorin interfaceRedBlackTree<T>- Returns:
- Either
REDorBLACK.
-
comparator
public java.util.Comparator<T> comparator()
Description copied from interface:RedBlackTreeReturns the underlyingComparatorof this RedBlackTree.- Specified by:
comparatorin interfaceRedBlackTree<T>- Returns:
- The comparator.
-
contains
public boolean contains(T value)
Description copied from interface:RedBlackTreeChecks, if thisRedBlackTreecontains the givenvalue.- Specified by:
containsin interfaceRedBlackTree<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:RedBlackTreeReturns the empty instance of this RedBlackTree.- Specified by:
emptyInstancein interfaceRedBlackTree<T>- Returns:
- An empty ReadBlackTree
-
find
public Option<T> find(T value)
Description copied from interface:RedBlackTreeFinds 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:
findin interfaceRedBlackTree<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:RedBlackTreeChecks if thisRedBlackTreeis empty, i.e. an instance ofLeaf.- Specified by:
isEmptyin interfaceRedBlackTree<T>- Returns:
- true, if it is empty, false otherwise.
-
left
public RedBlackTree<T> left()
Description copied from interface:RedBlackTreeReturns the left child if this is a non-empty node, otherwise throws.- Specified by:
leftin interfaceRedBlackTree<T>- Returns:
- The left child.
-
right
public RedBlackTree<T> right()
Description copied from interface:RedBlackTreeReturns the right child if this is a non-empty node, otherwise throws.- Specified by:
rightin interfaceRedBlackTree<T>- Returns:
- The right child.
-
size
public int size()
Description copied from interface:RedBlackTreeReturns the size of this tree.- Specified by:
sizein interfaceRedBlackTree<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:RedBlackTreeReturns the value of the current tree node or throws if this is empty.- Specified by:
valuein interfaceRedBlackTree<T>- Returns:
- The value.
-
toString
public java.lang.String toString()
Description copied from interface:RedBlackTreeReturns a Lisp like representation of this tree.- Specified by:
toStringin interfaceRedBlackTree<T>- Overrides:
toStringin classjava.lang.Object- Returns:
- This Tree as Lisp like String.
-
-