8038146: Clarify Map.Entry's connection to the underlying map

Reviewed-by: alanb
This commit is contained in:
Stuart Marks 2023-01-20 16:33:48 +00:00
parent b2d3622115
commit c6d5600396
4 changed files with 74 additions and 36 deletions

View file

@ -86,11 +86,18 @@ import java.util.function.Function;
* exception for its correctness: <em>the fail-fast behavior of iterators
* should be used only to detect bugs.</em>
*
* <p>All {@code Map.Entry} pairs returned by methods in this class
* and its views represent snapshots of mappings at the time they were
* produced. They do <strong>not</strong> support the {@code Entry.setValue}
* method. (Note however that it is possible to change mappings in the
* associated map using {@code put}.)
* <p>The methods
* {@link #ceilingEntry},
* {@link #firstEntry},
* {@link #floorEntry},
* {@link #higherEntry},
* {@link #lastEntry},
* {@link #lowerEntry},
* {@link #pollFirstEntry}, and
* {@link #pollLastEntry}
* return {@link Map.Entry} instances that represent snapshots of mappings as
* of the time of the call. They do <em>not</em> support mutation of the
* underlying map via the optional {@link Map.Entry#setValue setValue} method.
*
* <p>This class is a member of the
* <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
@ -419,7 +426,8 @@ public class TreeMap<K,V>
/**
* Gets the entry corresponding to the specified key; if no such entry
* exists, returns the entry for the greatest key less than the specified
* key; if no such entry exists, returns {@code null}.
* key; if no such entry exists (i.e., the least key in the Tree is greater
* than the specified key), returns {@code null}.
*/
final Entry<K,V> getFloorEntry(K key) {
Entry<K,V> p = root;
@ -450,10 +458,9 @@ public class TreeMap<K,V>
}
/**
* Gets the entry for the least key greater than the specified
* key; if no such entry exists, returns the entry for the least
* key greater than the specified key; if no such entry exists
* returns {@code null}.
* Returns the entry for the least key greater than the specified key; if
* no such entry exists (i.e., the greatest key in the Tree is less than
* or equal to the specified key), returns {@code null}.
*/
final Entry<K,V> getHigherEntry(K key) {
Entry<K,V> p = root;
@ -484,7 +491,7 @@ public class TreeMap<K,V>
/**
* Returns the entry for the greatest key less than the specified key; if
* no such entry exists (i.e., the least key in the Tree is greater than
* the specified key), returns {@code null}.
* or equal to the specified key), returns {@code null}.
*/
final Entry<K,V> getLowerEntry(K key) {
Entry<K,V> p = root;