Class java.util.TreeMap.Entry
java.lang.Object
|
+--java.util.TreeMap.Entry
- static class TreeMap.Entry
- extends java.lang.Object
- implements Map.Entry
Node in the Tree. Doubles as a means to pass key-value pairs back to
user (see Map.Entry).
Constructor Summary
|
TreeMap.Entry(java.lang.Object key,
java.lang.Object value,
TreeMap.Entry parent)
Make a new cell with given key, value, and parent, and with null
child links, and BLACK color. |
Method Summary
|
boolean
|
equals(java.lang.Object o)
|
java.lang.Object
|
getKey()
Returns the key. |
java.lang.Object
|
getValue()
Returns the value associated with the key. |
int
|
hashCode()
|
java.lang.Object
|
setValue(java.lang.Object value)
Replaces the value currently associated with the key with the given
value, and returns the old value. |
java.lang.String
|
toString()
|
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
key
java.lang.Object key
value
java.lang.Object value
left
TreeMap.Entry left
right
TreeMap.Entry right
parent
TreeMap.Entry parent
color
boolean color
TreeMap.Entry
TreeMap.Entry(java.lang.Object key,
java.lang.Object value,
TreeMap.Entry parent)
- Make a new cell with given key, value, and parent, and with null
child links, and BLACK color.
getKey
public java.lang.Object getKey()
- Returns the key.
- Specified by:
- getKey in interface Map.Entry
getValue
public java.lang.Object getValue()
- Returns the value associated with the key.
- Specified by:
- getValue in interface Map.Entry
setValue
public java.lang.Object setValue(java.lang.Object value)
- Replaces the value currently associated with the key with the given
value, and returns the old value.
- Specified by:
- setValue in interface Map.Entry
equals
public boolean equals(java.lang.Object o)
- Description copied from interface:
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. More formally, two
Entries e1
and e2
represent
the same mapping if (e1.getKey()==null ? e2.getKey()==null :
e1.getKey().equals(e2.getKey())) (e1.getValue()==null ?
e2.getValue()==null : e1.getValue().equals(e2.getValue()))
.
This ensures that the equals method works properly across different
implementations of the Map.Entry interface.
- Specified by:
- equals in interface Map.Entry
- Overrides:
- equals in class java.lang.Object
hashCode
public int hashCode()
- Description copied from interface:
Returns the hash code value for this Map.Entry. The hash code
of a Map.Entry e
is defined to be:
(e.getKey()==null ? 0 : e.getKey().hashCode()) ^
(e.getValue()==null ? 0 : e.getValue().hashCode())
This ensures that e1.equals(e2)
implies that
e1.hashCode()==e2.hashCode()
for any two Entries
e1
and e2
, as required by the general
contract of Object.hashCode.
- Specified by:
- hashCode in interface Map.Entry
- Overrides:
- hashCode in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
- toString in class java.lang.Object