Class TreeBidiMap.Node<K extends Comparable<K>,V extends Comparable<V>>
java.lang.Object
org.apache.commons.collections4.bidimap.TreeBidiMap.Node<K,V>
- Enclosing class:
TreeBidiMap<K extends Comparable<K>,
V extends Comparable<V>>
static class TreeBidiMap.Node<K extends Comparable<K>,V extends Comparable<V>>
extends Object
implements Map.Entry<K,V>, KeyValue<K,V>
A node used to store the data.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean[]
private boolean
private int
private final K
private final TreeBidiMap.Node<K,
V>[] private final TreeBidiMap.Node<K,
V>[] private final TreeBidiMap.Node<K,
V>[] private final V
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
copyColor
(TreeBidiMap.Node<K, V> node, TreeBidiMap.DataElement dataElement) Make this node the same color as anotherboolean
Compares the specified object with this entry for equality.private Object
getData
(TreeBidiMap.DataElement dataElement) getKey()
Gets the key.private TreeBidiMap.Node
<K, V> getLeft
(TreeBidiMap.DataElement dataElement) private TreeBidiMap.Node
<K, V> getParent
(TreeBidiMap.DataElement dataElement) Get the parent node.private TreeBidiMap.Node
<K, V> getRight
(TreeBidiMap.DataElement dataElement) getValue()
Gets the value.int
hashCode()
private boolean
isBlack
(TreeBidiMap.DataElement dataElement) Is this node black?private boolean
isLeftChild
(TreeBidiMap.DataElement dataElement) private boolean
isRed
(TreeBidiMap.DataElement dataElement) Is this node red?private boolean
isRightChild
(TreeBidiMap.DataElement dataElement) private void
setBlack
(TreeBidiMap.DataElement dataElement) Make this node black.private void
setLeft
(TreeBidiMap.Node<K, V> node, TreeBidiMap.DataElement dataElement) private void
setParent
(TreeBidiMap.Node<K, V> node, TreeBidiMap.DataElement dataElement) Set this node's parent node.private void
setRed
(TreeBidiMap.DataElement dataElement) Make this node red.private void
setRight
(TreeBidiMap.Node<K, V> node, TreeBidiMap.DataElement dataElement) Optional operation that is not permitted in this implementationprivate void
swapColors
(TreeBidiMap.Node<K, V> node, TreeBidiMap.DataElement dataElement) Exchange colors with another node.
-
Field Details
-
key
-
value
-
leftNode
-
rightNode
-
parentNode
-
blackColor
private final boolean[] blackColor -
hashcodeValue
private int hashcodeValue -
calculatedHashCode
private boolean calculatedHashCode
-
-
Constructor Details
-
Node
Make a new cell with given key and value, and with null links, and black (true) colors.- Parameters:
key
- the key of this nodevalue
- the value of this node
-
-
Method Details
-
getData
-
setLeft
-
getLeft
-
setRight
-
getRight
-
setParent
Set this node's parent node.- Parameters:
node
- the new parent nodedataElement
- eitherTreeBidiMap.DataElement.KEY
key} or thevalue
.
-
getParent
Get the parent node.- Parameters:
dataElement
- eitherTreeBidiMap.DataElement.KEY
key} or thevalue
.- Returns:
- the parent node, may be null
-
swapColors
Exchange colors with another node.- Parameters:
node
- the node to swap withdataElement
- eitherTreeBidiMap.DataElement.KEY
key} or thevalue
.
-
isBlack
Is this node black?- Parameters:
dataElement
- eitherTreeBidiMap.DataElement.KEY
key} or thevalue
.- Returns:
- true if black (which is represented as a true boolean)
-
isRed
Is this node red?- Parameters:
dataElement
- eitherTreeBidiMap.DataElement.KEY
key} or thevalue
.- Returns:
- true if non-black
-
setBlack
Make this node black.- Parameters:
dataElement
- eitherTreeBidiMap.DataElement.KEY
key} or thevalue
.
-
setRed
Make this node red.- Parameters:
dataElement
- eitherTreeBidiMap.DataElement.KEY
key} or thevalue
.
-
copyColor
Make this node the same color as another- Parameters:
node
- the node whose color we're adoptingdataElement
- eitherTreeBidiMap.DataElement.KEY
key} or thevalue
.
-
isLeftChild
-
isRightChild
-
getKey
Gets the key.- Specified by:
getKey
in interfaceKeyValue<K extends Comparable<K>,
V extends Comparable<V>> - Specified by:
getKey
in interfaceMap.Entry<K extends Comparable<K>,
V extends Comparable<V>> - Returns:
- the key corresponding to this entry.
-
getValue
Gets the value.- Specified by:
getValue
in interfaceKeyValue<K extends Comparable<K>,
V extends Comparable<V>> - Specified by:
getValue
in interfaceMap.Entry<K extends Comparable<K>,
V extends Comparable<V>> - Returns:
- the value corresponding to this entry.
-
setValue
Optional operation that is not permitted in this implementation- Specified by:
setValue
in interfaceMap.Entry<K extends Comparable<K>,
V extends Comparable<V>> - Parameters:
ignored
- this parameter is ignored.- Returns:
- does not return
- Throws:
UnsupportedOperationException
- always
-
equals
Compares the specified object with this entry for equality. Returns true if the given object is also a map entry and the two entries represent the same mapping.- Specified by:
equals
in interfaceMap.Entry<K extends Comparable<K>,
V extends Comparable<V>> - Overrides:
equals
in classObject
- Parameters:
obj
- the object to be compared for equality with this entry.- Returns:
- true if the specified object is equal to this entry.
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceMap.Entry<K extends Comparable<K>,
V extends Comparable<V>> - Overrides:
hashCode
in classObject
- Returns:
- the hash code value for this map entry.
-