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>
comparator
private static long
serialVersionUID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RedBlackTree.Color
color()
Return theRedBlackTree.Color
of this Red/Black Tree node.java.util.Comparator<T>
comparator()
Returns the underlyingComparator
of this RedBlackTree.boolean
contains(T value)
Checks, if thisRedBlackTree
contains 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.boolean
isEmpty()
Checks if thisRedBlackTree
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 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:RedBlackTree
Return theRedBlackTree.Color
of this Red/Black Tree node.An empty node is
BLACK
by definition.- Specified by:
color
in interfaceRedBlackTree<T>
- Returns:
- Either
RED
orBLACK
.
-
comparator
public java.util.Comparator<T> comparator()
Description copied from interface:RedBlackTree
Returns the underlyingComparator
of this RedBlackTree.- Specified by:
comparator
in interfaceRedBlackTree<T>
- Returns:
- The comparator.
-
contains
public boolean contains(T value)
Description copied from interface:RedBlackTree
Checks, if thisRedBlackTree
contains the givenvalue
.- Specified by:
contains
in 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:RedBlackTree
Returns the empty instance of this RedBlackTree.- Specified by:
emptyInstance
in interfaceRedBlackTree<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 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:RedBlackTree
Checks if thisRedBlackTree
is empty, i.e. an instance ofLeaf
.- Specified by:
isEmpty
in interfaceRedBlackTree<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 interfaceRedBlackTree<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 interfaceRedBlackTree<T>
- Returns:
- The right child.
-
size
public int size()
Description copied from interface:RedBlackTree
Returns the size of this tree.- Specified by:
size
in 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:RedBlackTree
Returns the value of the current tree node or throws if this is empty.- Specified by:
value
in interfaceRedBlackTree<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 interfaceRedBlackTree<T>
- Overrides:
toString
in classjava.lang.Object
- Returns:
- This Tree as Lisp like String.
-
-