java.lang.Object
org.jhotdraw8.icollection.impl.redblack.Node<K,V>
- Type Parameters:
K- Component type
- All Implemented Interfaces:
Iterable<Node<K,,V>> Map.Entry<K,,V> RedBlackTree<K,V>
A non-empty tree node.
This class has been derived from 'vavr' RedBlackTree.java.
- RedBlackTree.java. Copyright 2023 (c) vavr. MIT License.
- github.com
-
Method Summary
Modifier and TypeMethodDescriptionceiling(K value, @NonNull Comparator<? super K> comparator) Returns the leastNodein this tree greater than or equal to the given element, orEmptyif there is no such element.booleancolor()Return theColorof this Red/Black Tree node.booleancontains(K key, Comparator<? super K> comparator) Checks, if thisRedBlackTreecontains the givenkey.Returns the map entry of this RedBlackTree ornullif it is empty.booleanfind(K key, Comparator<? super K> comparator) Finds the value stored in this tree, if exists, by applying the underlying comparator to the tree elements and the given element.floor(K value, @NonNull Comparator<? super K> comparator) Returns the greatestNodein this tree less than or equal to the given element, orEmptyif there is no such element.getKey()Returns the key of the current tree node or throws if this is empty.getValue()Returns the value of the current tree node or throws if this is empty.inthashCode()higher(K value, @NonNull Comparator<? super K> comparator) Returns the leastNodein this tree strictly greater than the given element, orEmptyif there is no such element.booleanisEmpty()Checks if thisRedBlackTreeis empty, i.e.booleanisRed()Returns the key of this RedBlackTree ornullif it is empty.left()Returns the left child if this is a non-empty node, otherwise throws.lower(K value, @NonNull Comparator<? super K> comparator) Returns the greatestNodein this tree strictly less than the given element, orEmptyif there is no such element.<E> @Nullable EmapOrNull(@NonNull BiFunction<K, V, E> f) orElse(RedBlackTree<K, V> other) Returns thisRedBlackTreeif it is nonempty, otherwise return the alternative.right()Returns the right child if this is a non-empty node, otherwise throws.intsize()Returns the size of this tree.toString()Returns the value of this RedBlackTree ornullif it is empty.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.jhotdraw8.icollection.impl.redblack.RedBlackTree
delete, equals, insert, iterator, max, min, reverseIterator
-
Method Details
-
ceiling
Description copied from interface:RedBlackTreeReturns the leastNodein this tree greater than or equal to the given element, orEmptyif there is no such element.- Specified by:
ceilingin interfaceRedBlackTree<K,V>
-
color
public boolean color()Description copied from interface:RedBlackTreeReturn theColorof this Red/Black Tree node.An empty node is
BLACKby definition.- Specified by:
colorin interfaceRedBlackTree<K,V> - Returns:
- Either
REDorBLACK.
-
contains
Description copied from interface:RedBlackTreeChecks, if thisRedBlackTreecontains the givenkey.- Specified by:
containsin interfaceRedBlackTree<K,V> - Parameters:
key- A key.comparator-- Returns:
- true, if this tree contains the value, false otherwise.
-
entryOrNull
Description copied from interface:RedBlackTreeReturns the map entry of this RedBlackTree ornullif it is empty.- Specified by:
entryOrNullin interfaceRedBlackTree<K,V>
-
equals
-
find
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<K,V> - Parameters:
key- A valuecomparator-- Returns:
- Some value, if this tree contains a value equal to the given value according to the underlying comparator. Otherwise None.
-
floor
Description copied from interface:RedBlackTreeReturns the greatestNodein this tree less than or equal to the given element, orEmptyif there is no such element.- Specified by:
floorin interfaceRedBlackTree<K,V>
-
getKey
Description copied from interface:RedBlackTreeReturns the key of the current tree node or throws if this is empty. -
getValue
Description copied from interface:RedBlackTreeReturns the value of the current tree node or throws if this is empty. -
hashCode
public int hashCode() -
higher
Description copied from interface:RedBlackTreeReturns the leastNodein this tree strictly greater than the given element, orEmptyif there is no such element.- Specified by:
higherin interfaceRedBlackTree<K,V>
-
isEmpty
public boolean isEmpty()Description copied from interface:RedBlackTreeChecks if thisRedBlackTreeis empty, i.e. an instance ofLeaf.- Specified by:
isEmptyin interfaceRedBlackTree<K,V> - Returns:
- true, if it is empty, false otherwise.
-
isRed
public boolean isRed()- Specified by:
isRedin interfaceRedBlackTree<K,V>
-
keyOrNull
Description copied from interface:RedBlackTreeReturns the key of this RedBlackTree ornullif it is empty.- Specified by:
keyOrNullin interfaceRedBlackTree<K,V>
-
left
Description copied from interface:RedBlackTreeReturns the left child if this is a non-empty node, otherwise throws.- Specified by:
leftin interfaceRedBlackTree<K,V> - Returns:
- The left child.
-
lower
Description copied from interface:RedBlackTreeReturns the greatestNodein this tree strictly less than the given element, orEmptyif there is no such element.- Specified by:
lowerin interfaceRedBlackTree<K,V>
-
mapOrNull
- Specified by:
mapOrNullin interfaceRedBlackTree<K,V>
-
orElse
Description copied from interface:RedBlackTreeReturns thisRedBlackTreeif it is nonempty, otherwise return the alternative.- Specified by:
orElsein interfaceRedBlackTree<K,V>
-
right
Description copied from interface:RedBlackTreeReturns the right child if this is a non-empty node, otherwise throws.- Specified by:
rightin interfaceRedBlackTree<K,V> - Returns:
- The right child.
-
setValue
-
size
public int size()Description copied from interface:RedBlackTreeReturns the size of this tree.- Specified by:
sizein interfaceRedBlackTree<K,V> - Returns:
- the number of nodes of this tree and 0 if this is the empty tree
-
toLispString
- Specified by:
toLispStringin interfaceRedBlackTree<K,V>
-
toString
-
valueOrNull
Description copied from interface:RedBlackTreeReturns the value of this RedBlackTree ornullif it is empty.- Specified by:
valueOrNullin interfaceRedBlackTree<K,V>
-