--- jsr166/src/main/java/util/NavigableMap.java 2006/04/21 23:11:14 1.21 +++ jsr166/src/main/java/util/NavigableMap.java 2013/03/09 01:51:15 1.28 @@ -1,7 +1,7 @@ /* * Written by Doug Lea and Josh Bloch with assistance from members of JCP * JSR-166 Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ package java.util; @@ -9,13 +9,13 @@ package java.util; /** * A {@link SortedMap} extended with navigation methods returning the * closest matches for given search targets. Methods - * {@code lowerEntry}, {@code floorEntry}, {@code ceilingEntry}, - * and {@code higherEntry} return {@code Map.Entry} objects + * {@link #lowerEntry}, {@link #floorEntry}, {@link #ceilingEntry}, + * and {@link #higherEntry} return {@code Map.Entry} objects * associated with keys respectively less than, less than or equal, * greater than or equal, and greater than a given key, returning * {@code null} if there is no such key. Similarly, methods - * {@code lowerKey}, {@code floorKey}, {@code ceilingKey}, and - * {@code higherKey} return only the associated keys. All of these + * {@link #lowerKey}, {@link #floorKey}, {@link #ceilingKey}, and + * {@link #higherKey} return only the associated keys. All of these * methods are designed for locating, not traversing entries. * *

A {@code NavigableMap} may be accessed and traversed in either @@ -30,20 +30,31 @@ package java.util; * Submaps of any {@code NavigableMap} must implement the {@code * NavigableMap} interface. * - *

This interface additionally defines methods {@code firstEntry}, - * {@code pollFirstEntry}, {@code lastEntry}, and - * {@code pollLastEntry} that return and/or remove the least and + *

This interface additionally defines methods {@link #firstEntry}, + * {@link #pollFirstEntry}, {@link #lastEntry}, and + * {@link #pollLastEntry} that return and/or remove the least and * greatest mappings, if any exist, else returning {@code null}. * - *

Implementations of entry-returning methods are expected to + *

Implementations of entry-returning methods are expected to * return {@code Map.Entry} pairs representing snapshots of mappings * at the time they were produced, and thus generally do not * support the optional {@code Entry.setValue} method. Note however * that it is possible to change mappings in the associated map using * method {@code put}. * + *

Methods + * {@link #subMap(Object, Object) subMap(K, K)}, + * {@link #headMap(Object) headMap(K)}, and + * {@link #tailMap(Object) tailMap(K)} + * are specified to return {@code SortedMap} to allow existing + * implementations of {@code SortedMap} to be compatibly retrofitted to + * implement {@code NavigableMap}, but extensions and implementations + * of this interface are encouraged to override these methods to return + * {@code NavigableMap}. Similarly, + * {@link #keySet()} can be overridden to return {@code NavigableSet}. + * *

This interface is a member of the - * + * * Java Collections Framework. * * @author Doug Lea @@ -206,50 +217,51 @@ public interface NavigableMap exten Map.Entry pollLastEntry(); /** - * Returns a {@link NavigableMap} view of the mappings contained in this - * map in descending order. The descending map is backed by this map, so - * changes to the map are reflected in the descending map, and vice-versa. - * If either map is modified while an iteration over a collection view of - * the other map is in progress (except through the iterator's own - * {@code remove} operation), the results of the iteration are undefined. + * Returns a reverse order view of the mappings contained in this map. + * The descending map is backed by this map, so changes to the map are + * reflected in the descending map, and vice-versa. If either map is + * modified while an iteration over a collection view of either map + * is in progress (except through the iterator's own {@code remove} + * operation), the results of the iteration are undefined. + * + *

The returned map has an ordering equivalent to + * {@link Collections#reverseOrder(Comparator) Collections.reverseOrder}{@code (comparator())}. + * The expression {@code m.descendingMap().descendingMap()} returns a + * view of {@code m} essentially equivalent to {@code m}. * - * @return a navigable map view of the mappings contained in this map, - * sorted in descending order + * @return a reverse order view of this map */ NavigableMap descendingMap(); /** - * Returns a navigable set view of the keys contained in this navigable - * map. The set is backed by the map, so changes to the map are reflected - * in the set, and vice-versa. If the map is modified while an iteration - * over the set is in progress (except through the iterator's own - * {@code remove} operation), the results of the iteration are undefined. - * The set supports element removal, which removes the corresponding - * mapping from the map, via the {@code Iterator.remove}, - * {@code Set.remove}, {@code removeAll}, {@code retainAll}, and - * {@code clear} operations. It does not support the {@code add} or - * {@code addAll} operations. + * Returns a {@link NavigableSet} view of the keys contained in this map. + * The set's iterator returns the keys in ascending order. + * The set is backed by the map, so changes to the map are reflected in + * the set, and vice-versa. If the map is modified while an iteration + * over the set is in progress (except through the iterator's own {@code + * remove} operation), the results of the iteration are undefined. The + * set supports element removal, which removes the corresponding mapping + * from the map, via the {@code Iterator.remove}, {@code Set.remove}, + * {@code removeAll}, {@code retainAll}, and {@code clear} operations. + * It does not support the {@code add} or {@code addAll} operations. * - * @return a navigable set view of the keys contained in this navigable map + * @return a navigable set view of the keys in this map */ NavigableSet navigableKeySet(); /** - * Returns a {@link NavigableSet} view of the keys contained in this map. + * Returns a reverse order {@link NavigableSet} view of the keys contained in this map. * The set's iterator returns the keys in descending order. - * The set is backed by the map, so changes to the map are - * reflected in the set, and vice-versa. If the map is modified - * while an iteration over the set is in progress (except through - * the iterator's own {@code remove} operation), the results of - * the iteration are undefined. The set supports element removal, - * which removes the corresponding mapping from the map, via the - * {@code Iterator.remove}, {@code Set.remove}, - * {@code removeAll}, {@code retainAll}, and {@code clear} - * operations. It does not support the {@code add} or {@code addAll} - * operations. + * The set is backed by the map, so changes to the map are reflected in + * the set, and vice-versa. If the map is modified while an iteration + * over the set is in progress (except through the iterator's own {@code + * remove} operation), the results of the iteration are undefined. The + * set supports element removal, which removes the corresponding mapping + * from the map, via the {@code Iterator.remove}, {@code Set.remove}, + * {@code removeAll}, {@code retainAll}, and {@code clear} operations. + * It does not support the {@code add} or {@code addAll} operations. * - * @return a set view of the keys contained in this map, sorted in - * descending order + * @return a reverse order navigable set view of the keys in this map */ NavigableSet descendingKeySet(); @@ -349,10 +361,9 @@ public interface NavigableMap exten NavigableMap tailMap(K fromKey, boolean inclusive); /** - * Equivalent to {@code subMap(fromKey, true, toKey, false)} - * but with a return type conforming to the {@code SortedMap} interface. + * {@inheritDoc} * - *

{@inheritDoc} + *

Equivalent to {@code subMap(fromKey, true, toKey, false)}. * * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} @@ -361,10 +372,9 @@ public interface NavigableMap exten SortedMap subMap(K fromKey, K toKey); /** - * Equivalent to {@code headMap(toKey, false)} - * but with a return type conforming to the {@code SortedMap} interface. + * {@inheritDoc} * - *

{@inheritDoc} + *

Equivalent to {@code headMap(toKey, false)}. * * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} @@ -373,10 +383,9 @@ public interface NavigableMap exten SortedMap headMap(K toKey); /** - * Equivalent to {@code tailMap(fromKey, true)} - * but with a return type conforming to the {@code SortedMap} interface. + * {@inheritDoc} * - *

{@inheritDoc} + *

Equivalent to {@code tailMap(fromKey, true)}. * * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc}