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; |
35 |
|
* {@code pollLastEntry} that return and/or remove the least and |
36 |
|
* greatest mappings, if any exist, else returning {@code null}. |
37 |
|
* |
38 |
< |
* <p> Implementations of entry-returning methods are expected to |
38 |
> |
* <p>Implementations of entry-returning methods are expected to |
39 |
|
* return {@code Map.Entry} pairs representing snapshots of mappings |
40 |
|
* at the time they were produced, and thus generally do <em>not</em> |
41 |
|
* support the optional {@code Entry.setValue} method. Note however |
42 |
|
* that it is possible to change mappings in the associated map using |
43 |
|
* method {@code put}. |
44 |
|
* |
45 |
+ |
* <p>Methods |
46 |
+ |
* {@link #subMap(Object, Object) subMap(K, K)}, |
47 |
+ |
* {@link #headMap(Object) headMap(K)}, and |
48 |
+ |
* {@link #tailMap(Object) tailMap(K)} |
49 |
+ |
* are specified to return {@code SortedMap} to allow existing |
50 |
+ |
* implementations of {@code SortedMap} to be compatibly retrofitted to |
51 |
+ |
* implement {@code NavigableMap}, but extensions and implementations |
52 |
+ |
* of this interface are encouraged to override these methods to return |
53 |
+ |
* {@code NavigableMap}. Similarly, |
54 |
+ |
* {@link #keySet()} can be overriden to return {@code NavigableSet}. |
55 |
+ |
* |
56 |
|
* <p>This interface is a member of the |
57 |
< |
* <a href="{@docRoot}/../guide/collections/index.html"> |
57 |
> |
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> |
58 |
|
* Java Collections Framework</a>. |
59 |
|
* |
60 |
|
* @author Doug Lea |
217 |
|
Map.Entry<K,V> pollLastEntry(); |
218 |
|
|
219 |
|
/** |
220 |
< |
* Returns a {@link NavigableMap} view of the mappings contained in this |
221 |
< |
* map in descending order. The descending map is backed by this map, so |
222 |
< |
* changes to the map are reflected in the descending map, and vice-versa. |
223 |
< |
* If either map is modified while an iteration over a collection view of |
224 |
< |
* the other map is in progress (except through the iterator's own |
225 |
< |
* {@code remove} operation), the results of the iteration are undefined. |
220 |
> |
* Returns a reverse order view of the mappings contained in this map. |
221 |
> |
* The descending map is backed by this map, so changes to the map are |
222 |
> |
* reflected in the descending map, and vice-versa. If either map is |
223 |
> |
* modified while an iteration over a collection view of either map |
224 |
> |
* is in progress (except through the iterator's own {@code remove} |
225 |
> |
* operation), the results of the iteration are undefined. |
226 |
> |
* |
227 |
> |
* <p>The returned map has an ordering equivalent to |
228 |
> |
* <tt>{@link Collections#reverseOrder(Comparator) Collections.reverseOrder}(comparator())</tt>. |
229 |
> |
* The expression {@code m.descendingMap().descendingMap()} returns a |
230 |
> |
* view of {@code m} essentially equivalent to {@code m}. |
231 |
|
* |
232 |
< |
* @return a navigable map view of the mappings contained in this map, |
217 |
< |
* sorted in descending order |
232 |
> |
* @return a reverse order view of this map |
233 |
|
*/ |
234 |
|
NavigableMap<K,V> descendingMap(); |
235 |
|
|
236 |
|
/** |
237 |
< |
* Returns a navigable set view of the keys contained in this navigable |
238 |
< |
* map. The set is backed by the map, so changes to the map are reflected |
239 |
< |
* in the set, and vice-versa. If the map is modified while an iteration |
240 |
< |
* over the set is in progress (except through the iterator's own |
241 |
< |
* {@code remove} operation), the results of the iteration are undefined. |
242 |
< |
* The set supports element removal, which removes the corresponding |
243 |
< |
* mapping from the map, via the {@code Iterator.remove}, |
244 |
< |
* {@code Set.remove}, {@code removeAll}, {@code retainAll}, and |
245 |
< |
* {@code clear} operations. It does not support the {@code add} or |
246 |
< |
* {@code addAll} operations. |
237 |
> |
* Returns a {@link NavigableSet} view of the keys contained in this map. |
238 |
> |
* The set's iterator returns the keys in ascending order. |
239 |
> |
* The set is backed by the map, so changes to the map are reflected in |
240 |
> |
* the set, and vice-versa. If the map is modified while an iteration |
241 |
> |
* over the set is in progress (except through the iterator's own {@code |
242 |
> |
* remove} operation), the results of the iteration are undefined. The |
243 |
> |
* set supports element removal, which removes the corresponding mapping |
244 |
> |
* from the map, via the {@code Iterator.remove}, {@code Set.remove}, |
245 |
> |
* {@code removeAll}, {@code retainAll}, and {@code clear} operations. |
246 |
> |
* It does not support the {@code add} or {@code addAll} operations. |
247 |
|
* |
248 |
< |
* @return a navigable set view of the keys contained in this navigable map |
248 |
> |
* @return a navigable set view of the keys in this map |
249 |
|
*/ |
250 |
|
NavigableSet<K> navigableKeySet(); |
251 |
|
|
252 |
|
/** |
253 |
< |
* Returns a {@link NavigableSet} view of the keys contained in this map. |
253 |
> |
* Returns a reverse order {@link NavigableSet} view of the keys contained in this map. |
254 |
|
* The set's iterator returns the keys in descending order. |
255 |
< |
* The set is backed by the map, so changes to the map are |
256 |
< |
* reflected in the set, and vice-versa. If the map is modified |
257 |
< |
* while an iteration over the set is in progress (except through |
258 |
< |
* the iterator's own {@code remove} operation), the results of |
259 |
< |
* the iteration are undefined. The set supports element removal, |
260 |
< |
* which removes the corresponding mapping from the map, via the |
261 |
< |
* {@code Iterator.remove}, {@code Set.remove}, |
262 |
< |
* {@code removeAll}, {@code retainAll}, and {@code clear} |
248 |
< |
* operations. It does not support the {@code add} or {@code addAll} |
249 |
< |
* operations. |
255 |
> |
* The set is backed by the map, so changes to the map are reflected in |
256 |
> |
* the set, and vice-versa. If the map is modified while an iteration |
257 |
> |
* over the set is in progress (except through the iterator's own {@code |
258 |
> |
* remove} operation), the results of the iteration are undefined. The |
259 |
> |
* set supports element removal, which removes the corresponding mapping |
260 |
> |
* from the map, via the {@code Iterator.remove}, {@code Set.remove}, |
261 |
> |
* {@code removeAll}, {@code retainAll}, and {@code clear} operations. |
262 |
> |
* It does not support the {@code add} or {@code addAll} operations. |
263 |
|
* |
264 |
< |
* @return a set view of the keys contained in this map, sorted in |
252 |
< |
* descending order |
264 |
> |
* @return a reverse order navigable set view of the keys in this map |
265 |
|
*/ |
266 |
|
NavigableSet<K> descendingKeySet(); |
267 |
|
|
361 |
|
NavigableMap<K,V> tailMap(K fromKey, boolean inclusive); |
362 |
|
|
363 |
|
/** |
364 |
< |
* Equivalent to {@code subMap(fromKey, true, toKey, false)} |
353 |
< |
* but with a return type conforming to the {@code SortedMap} interface. |
364 |
> |
* {@inheritDoc} |
365 |
|
* |
366 |
< |
* <p>{@inheritDoc} |
366 |
> |
* <p>Equivalent to {@code subMap(fromKey, true, toKey, false)}. |
367 |
|
* |
368 |
|
* @throws ClassCastException {@inheritDoc} |
369 |
|
* @throws NullPointerException {@inheritDoc} |
372 |
|
SortedMap<K,V> subMap(K fromKey, K toKey); |
373 |
|
|
374 |
|
/** |
375 |
< |
* Equivalent to {@code headMap(toKey, false)} |
365 |
< |
* but with a return type conforming to the {@code SortedMap} interface. |
375 |
> |
* {@inheritDoc} |
376 |
|
* |
377 |
< |
* <p>{@inheritDoc} |
377 |
> |
* <p>Equivalent to {@code headMap(toKey, false)}. |
378 |
|
* |
379 |
|
* @throws ClassCastException {@inheritDoc} |
380 |
|
* @throws NullPointerException {@inheritDoc} |
383 |
|
SortedMap<K,V> headMap(K toKey); |
384 |
|
|
385 |
|
/** |
386 |
< |
* Equivalent to {@code tailMap(fromKey, true)} |
377 |
< |
* but with a return type conforming to the {@code SortedMap} interface. |
386 |
> |
* {@inheritDoc} |
387 |
|
* |
388 |
< |
* <p>{@inheritDoc} |
388 |
> |
* <p>Equivalent to {@code tailMap(fromKey, true)}. |
389 |
|
* |
390 |
|
* @throws ClassCastException {@inheritDoc} |
391 |
|
* @throws NullPointerException {@inheritDoc} |