ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/NavigableMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/NavigableMap.java (file contents):
Revision 1.20 by jsr166, Fri Apr 21 22:42:27 2006 UTC vs.
Revision 1.31 by jsr166, Sat May 6 06:49:46 2017 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea and Josh Bloch with assistance from members of JCP
3   * JSR-166 Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   package java.util;
# Line 9 | Line 9 | package java.util;
9   /**
10   * A {@link SortedMap} extended with navigation methods returning the
11   * closest matches for given search targets. Methods
12 < * {@code lowerEntry}, {@code floorEntry}, {@code ceilingEntry},
13 < * and {@code higherEntry} return {@code Map.Entry} objects
12 > * {@link #lowerEntry}, {@link #floorEntry}, {@link #ceilingEntry},
13 > * and {@link #higherEntry} return {@code Map.Entry} objects
14   * associated with keys respectively less than, less than or equal,
15   * greater than or equal, and greater than a given key, returning
16   * {@code null} if there is no such key.  Similarly, methods
17 < * {@code lowerKey}, {@code floorKey}, {@code ceilingKey}, and
18 < * {@code higherKey} return only the associated keys. All of these
17 > * {@link #lowerKey}, {@link #floorKey}, {@link #ceilingKey}, and
18 > * {@link #higherKey} return only the associated keys. All of these
19   * methods are designed for locating, not traversing entries.
20   *
21   * <p>A {@code NavigableMap} may be accessed and traversed in either
22 < * ascending or descending key order.  The {@code descendingMap}
22 > * ascending or descending key order.  The {@link #descendingMap}
23   * method returns a view of the map with the senses of all relational
24   * and directional methods inverted. The performance of ascending
25   * operations and views is likely to be faster than that of descending
26 < * ones.  Methods {@code subMap}, {@code headMap},
27 < * and {@code tailMap} differ from the like-named {@code
28 < * SortedMap} methods in accepting additional arguments describing
29 < * whether lower and upper bounds are inclusive versus exclusive.
30 < * Submaps of any {@code NavigableMap} must implement the {@code
31 < * NavigableMap} interface.
26 > * ones.  Methods
27 > * {@link #subMap(Object, boolean, Object, boolean) subMap(K, boolean, K, boolean)},
28 > * {@link #headMap(Object, boolean) headMap(K, boolean)}, and
29 > * {@link #tailMap(Object, boolean) tailMap(K, boolean)}
30 > * differ from the like-named {@code SortedMap} methods in accepting
31 > * additional arguments describing whether lower and upper bounds are
32 > * inclusive versus exclusive.  Submaps of any {@code NavigableMap}
33 > * must implement the {@code NavigableMap} interface.
34   *
35 < * <p>This interface additionally defines methods {@code firstEntry},
36 < * {@code pollFirstEntry}, {@code lastEntry}, and
37 < * {@code pollLastEntry} that return and/or remove the least and
35 > * <p>This interface additionally defines methods {@link #firstEntry},
36 > * {@link #pollFirstEntry}, {@link #lastEntry}, and
37 > * {@link #pollLastEntry} that return and/or remove the least and
38   * greatest mappings, if any exist, else returning {@code null}.
39   *
40 < * <p> Implementations of entry-returning methods are expected to
40 > * <p>Implementations of entry-returning methods are expected to
41   * return {@code Map.Entry} pairs representing snapshots of mappings
42   * at the time they were produced, and thus generally do <em>not</em>
43   * support the optional {@code Entry.setValue} method. Note however
44   * that it is possible to change mappings in the associated map using
45   * method {@code put}.
46   *
47 + * <p>Methods
48 + * {@link #subMap(Object, Object) subMap(K, K)},
49 + * {@link #headMap(Object) headMap(K)}, and
50 + * {@link #tailMap(Object) tailMap(K)}
51 + * are specified to return {@code SortedMap} to allow existing
52 + * implementations of {@code SortedMap} to be compatibly retrofitted to
53 + * implement {@code NavigableMap}, but extensions and implementations
54 + * of this interface are encouraged to override these methods to return
55 + * {@code NavigableMap}.  Similarly,
56 + * {@link #keySet()} can be overridden to return {@link NavigableSet}.
57 + *
58   * <p>This interface is a member of the
59 < * <a href="{@docRoot}/../guide/collections/index.html">
59 > * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
60   * Java Collections Framework</a>.
61   *
62   * @author Doug Lea
# Line 206 | Line 219 | public interface NavigableMap<K,V> exten
219      Map.Entry<K,V> pollLastEntry();
220  
221      /**
222 <     * Returns a {@link NavigableMap} view of the mappings contained in this
223 <     * map in descending order.  The descending map is backed by this map, so
224 <     * changes to the map are reflected in the descending map, and vice-versa.
225 <     * If either map is modified while an iteration over a collection view of
226 <     * the other map is in progress (except through the iterator's own
227 <     * {@code remove} operation), the results of the iteration are undefined.
222 >     * Returns a reverse order view of the mappings contained in this map.
223 >     * The descending map is backed by this map, so changes to the map are
224 >     * reflected in the descending map, and vice-versa.  If either map is
225 >     * modified while an iteration over a collection view of either map
226 >     * is in progress (except through the iterator's own {@code remove}
227 >     * operation), the results of the iteration are undefined.
228 >     *
229 >     * <p>The returned map has an ordering equivalent to
230 >     * {@link Collections#reverseOrder(Comparator) Collections.reverseOrder}{@code (comparator())}.
231 >     * The expression {@code m.descendingMap().descendingMap()} returns a
232 >     * view of {@code m} essentially equivalent to {@code m}.
233       *
234 <     * @return a navigable map view of the mappings contained in this map,
217 <     *         sorted in descending order
234 >     * @return a reverse order view of this map
235       */
236      NavigableMap<K,V> descendingMap();
237  
238      /**
239 <     * Returns a navigable set view of the keys contained in this navigable
240 <     * map.  The set is backed by the map, so changes to the map are reflected
241 <     * in the set, and vice-versa.  If the map is modified while an iteration
242 <     * over the set is in progress (except through the iterator's own
243 <     * {@code remove} operation), the results of the iteration are undefined.
244 <     * The set supports element removal, which removes the corresponding
245 <     * mapping from the map, via the {@code Iterator.remove},
246 <     * {@code Set.remove}, {@code removeAll}, {@code retainAll}, and
247 <     * {@code clear} operations.  It does not support the {@code add} or
248 <     * {@code addAll} operations.
239 >     * Returns a {@link NavigableSet} view of the keys contained in this map.
240 >     * The set's iterator returns the keys in ascending order.
241 >     * The set is backed by the map, so changes to the map are reflected in
242 >     * the set, and vice-versa.  If the map is modified while an iteration
243 >     * over the set is in progress (except through the iterator's own {@code
244 >     * remove} operation), the results of the iteration are undefined.  The
245 >     * set supports element removal, which removes the corresponding mapping
246 >     * from the map, via the {@code Iterator.remove}, {@code Set.remove},
247 >     * {@code removeAll}, {@code retainAll}, and {@code clear} operations.
248 >     * It does not support the {@code add} or {@code addAll} operations.
249       *
250 <     * @return a navigable set view of the keys contained in this navigable map
250 >     * @return a navigable set view of the keys in this map
251       */
252      NavigableSet<K> navigableKeySet();
253  
254      /**
255 <     * Returns a {@link NavigableSet} view of the keys contained in this map.
255 >     * Returns a reverse order {@link NavigableSet} view of the keys contained in this map.
256       * The set's iterator returns the keys in descending order.
257 <     * The set is backed by the map, so changes to the map are
258 <     * reflected in the set, and vice-versa.  If the map is modified
259 <     * while an iteration over the set is in progress (except through
260 <     * the iterator's own <tt>remove</tt> operation), the results of
261 <     * the iteration are undefined.  The set supports element removal,
262 <     * which removes the corresponding mapping from the map, via the
263 <     * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>,
264 <     * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt>
248 <     * operations.  It does not support the <tt>add</tt> or <tt>addAll</tt>
249 <     * operations.
257 >     * The set is backed by the map, so changes to the map are reflected in
258 >     * the set, and vice-versa.  If the map is modified while an iteration
259 >     * over the set is in progress (except through the iterator's own {@code
260 >     * remove} operation), the results of the iteration are undefined.  The
261 >     * set supports element removal, which removes the corresponding mapping
262 >     * from the map, via the {@code Iterator.remove}, {@code Set.remove},
263 >     * {@code removeAll}, {@code retainAll}, and {@code clear} operations.
264 >     * It does not support the {@code add} or {@code addAll} operations.
265       *
266 <     * @return a set view of the keys contained in this map, sorted in
252 <     *         descending order
266 >     * @return a reverse order navigable set view of the keys in this map
267       */
268      NavigableSet<K> descendingKeySet();
269  
# Line 257 | Line 271 | public interface NavigableMap<K,V> exten
271       * Returns a view of the portion of this map whose keys range from
272       * {@code fromKey} to {@code toKey}.  If {@code fromKey} and
273       * {@code toKey} are equal, the returned map is empty unless
274 <     * {@code fromExclusive} and {@code toExclusive} are both true.  The
274 >     * {@code fromInclusive} and {@code toInclusive} are both true.  The
275       * returned map is backed by this map, so changes in the returned map are
276       * reflected in this map, and vice-versa.  The returned map supports all
277       * optional map operations that this map supports.
# Line 349 | Line 363 | public interface NavigableMap<K,V> exten
363      NavigableMap<K,V> tailMap(K fromKey, boolean inclusive);
364  
365      /**
366 <     * Equivalent to {@code subMap(fromKey, true, toKey, false)}
353 <     * but with a return type conforming to the {@code SortedMap} interface.
366 >     * {@inheritDoc}
367       *
368 <     * <p>{@inheritDoc}
368 >     * <p>Equivalent to {@code subMap(fromKey, true, toKey, false)}.
369       *
370       * @throws ClassCastException       {@inheritDoc}
371       * @throws NullPointerException     {@inheritDoc}
# Line 361 | Line 374 | public interface NavigableMap<K,V> exten
374      SortedMap<K,V> subMap(K fromKey, K toKey);
375  
376      /**
377 <     * Equivalent to {@code headMap(toKey, false)}
365 <     * but with a return type conforming to the {@code SortedMap} interface.
377 >     * {@inheritDoc}
378       *
379 <     * <p>{@inheritDoc}
379 >     * <p>Equivalent to {@code headMap(toKey, false)}.
380       *
381       * @throws ClassCastException       {@inheritDoc}
382       * @throws NullPointerException     {@inheritDoc}
# Line 373 | Line 385 | public interface NavigableMap<K,V> exten
385      SortedMap<K,V> headMap(K toKey);
386  
387      /**
388 <     * Equivalent to {@code tailMap(fromKey, true)}
377 <     * but with a return type conforming to the {@code SortedMap} interface.
388 >     * {@inheritDoc}
389       *
390 <     * <p>{@inheritDoc}
390 >     * <p>Equivalent to {@code tailMap(fromKey, true)}.
391       *
392       * @throws ClassCastException       {@inheritDoc}
393       * @throws NullPointerException     {@inheritDoc}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines