1 |
|
/* |
2 |
< |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
< |
* Expert Group and released to the public domain, as explained at |
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 |
5 |
|
*/ |
6 |
|
|
9 |
|
/** |
10 |
|
* A {@link SortedMap} extended with navigation methods returning the |
11 |
|
* closest matches for given search targets. Methods |
12 |
< |
* <tt>lowerEntry</tt>, <tt>floorEntry</tt>, <tt>ceilingEntry</tt>, |
13 |
< |
* and <tt>higherEntry</tt> return <tt>Map.Entry</tt> objects |
12 |
> |
* {@code lowerEntry}, {@code floorEntry}, {@code ceilingEntry}, |
13 |
> |
* and {@code 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 |
< |
* <tt>null</tt> if there is no such key. Similarly, methods |
17 |
< |
* <tt>lowerKey</tt>, <tt>floorKey</tt>, <tt>ceilingKey</tt>, and |
18 |
< |
* <tt>higherKey</tt> return only the associated keys. All of these |
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 |
19 |
|
* methods are designed for locating, not traversing entries. |
20 |
|
* |
21 |
< |
* <p>A <tt>NavigableMap</tt> may be viewed and traversed in either |
22 |
< |
* ascending or descending key order. The <tt>Map</tt> methods |
23 |
< |
* <tt>keySet</tt> and <tt>entrySet</tt> return ascending views, and |
24 |
< |
* the additional methods <tt>descendingKeySet</tt> and |
25 |
< |
* <tt>descendingEntrySet</tt> return descending views. The |
26 |
< |
* performance of ascending traversals is likely to be faster than |
27 |
< |
* descending traversals. Notice that it is possible to perform |
28 |
< |
* subrange traversals in either direction using <tt>navigableSubMap</tt>. |
29 |
< |
* Methods <tt>navigableSubMap</tt>, <tt>navigableHeadMap</tt>, and |
30 |
< |
* <tt>navigableTailMap</tt> differ from the similarly named |
31 |
< |
* <tt>SortedMap</tt> methods only in that the returned maps |
32 |
< |
* are guaranteed to obey the <tt>NavigableMap</tt> interface. |
21 |
> |
* <p>A {@code NavigableMap} may be accessed and traversed in either |
22 |
> |
* ascending or descending key order. The {@code 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. |
32 |
|
* |
33 |
< |
* <p>This interface additionally defines methods <tt>firstEntry</tt>, |
34 |
< |
* <tt>pollFirstEntry</tt>, <tt>lastEntry</tt>, and |
35 |
< |
* <tt>pollLastEntry</tt> that return and/or remove the least and |
36 |
< |
* greatest mappings, if any exist, else returning <tt>null</tt>. |
33 |
> |
* <p>This interface additionally defines methods {@code firstEntry}, |
34 |
> |
* {@code pollFirstEntry}, {@code lastEntry}, and |
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 |
39 |
< |
* return <tt>Map.Entry</tt> pairs representing snapshots of mappings |
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 <tt>Entry.setValue</tt> method. Note however |
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 <tt>put</tt>. |
43 |
> |
* method {@code put}. |
44 |
> |
* |
45 |
> |
* <p>This interface is a member of the |
46 |
> |
* <a href="{@docRoot}/../guide/collections/index.html"> |
47 |
> |
* Java Collections Framework</a>. |
48 |
|
* |
49 |
|
* @author Doug Lea |
50 |
+ |
* @author Josh Bloch |
51 |
|
* @param <K> the type of keys maintained by this map |
52 |
|
* @param <V> the type of mapped values |
53 |
+ |
* @since 1.6 |
54 |
|
*/ |
55 |
|
public interface NavigableMap<K,V> extends SortedMap<K,V> { |
56 |
|
/** |
57 |
< |
* Returns a key-value mapping associated with the least key |
58 |
< |
* greater than or equal to the given key, or <tt>null</tt> if there is |
59 |
< |
* no such entry. |
57 |
> |
* Returns a key-value mapping associated with the greatest key |
58 |
> |
* strictly less than the given key, or {@code null} if there is |
59 |
> |
* no such key. |
60 |
|
* |
61 |
< |
* @param key the key. |
62 |
< |
* @return an Entry associated with ceiling of given key, or <tt>null</tt> |
63 |
< |
* if there is no such Entry. |
64 |
< |
* @throws ClassCastException if key cannot be compared with the keys |
65 |
< |
* currently in the map. |
66 |
< |
* @throws NullPointerException if key is <tt>null</tt> and this map |
67 |
< |
* does not support <tt>null</tt> keys. |
61 |
> |
* @param key the key |
62 |
> |
* @return an entry with the greatest key less than {@code key}, |
63 |
> |
* or {@code null} if there is no such key |
64 |
> |
* @throws ClassCastException if the specified key cannot be compared |
65 |
> |
* with the keys currently in the map |
66 |
> |
* @throws NullPointerException if the specified key is null |
67 |
> |
* and this map does not permit null keys |
68 |
|
*/ |
69 |
< |
Map.Entry<K,V> ceilingEntry(K key); |
69 |
> |
Map.Entry<K,V> lowerEntry(K key); |
70 |
|
|
71 |
|
/** |
72 |
< |
* Returns least key greater than or equal to the given key, or |
73 |
< |
* <tt>null</tt> if there is no such key. |
72 |
> |
* Returns the greatest key strictly less than the given key, or |
73 |
> |
* {@code null} if there is no such key. |
74 |
|
* |
75 |
< |
* @param key the key. |
76 |
< |
* @return the ceiling key, or <tt>null</tt> |
77 |
< |
* if there is no such key. |
78 |
< |
* @throws ClassCastException if key cannot be compared with the keys |
79 |
< |
* currently in the map. |
80 |
< |
* @throws NullPointerException if key is <tt>null</tt> and this map |
81 |
< |
* does not support <tt>null</tt> keys. |
75 |
> |
* @param key the key |
76 |
> |
* @return the greatest key less than {@code key}, |
77 |
> |
* or {@code null} if there is no such key |
78 |
> |
* @throws ClassCastException if the specified key cannot be compared |
79 |
> |
* with the keys currently in the map |
80 |
> |
* @throws NullPointerException if the specified key is null |
81 |
> |
* and this map does not permit null keys |
82 |
|
*/ |
83 |
< |
K ceilingKey(K key); |
83 |
> |
K lowerKey(K key); |
84 |
|
|
85 |
|
/** |
86 |
< |
* Returns a key-value mapping associated with the greatest |
87 |
< |
* key strictly less than the given key, or <tt>null</tt> if there is no |
88 |
< |
* such entry. |
86 |
> |
* Returns a key-value mapping associated with the greatest key |
87 |
> |
* less than or equal to the given key, or {@code null} if there |
88 |
> |
* is no such key. |
89 |
|
* |
90 |
< |
* @param key the key. |
91 |
< |
* @return an Entry with greatest key less than the given |
92 |
< |
* key, or <tt>null</tt> if there is no such Entry. |
93 |
< |
* @throws ClassCastException if key cannot be compared with the keys |
94 |
< |
* currently in the map. |
95 |
< |
* @throws NullPointerException if key is <tt>null</tt> and this map |
96 |
< |
* does not support <tt>null</tt> keys. |
90 |
> |
* @param key the key |
91 |
> |
* @return an entry with the greatest key less than or equal to |
92 |
> |
* {@code key}, or {@code null} if there is no such key |
93 |
> |
* @throws ClassCastException if the specified key cannot be compared |
94 |
> |
* with the keys currently in the map |
95 |
> |
* @throws NullPointerException if the specified key is null |
96 |
> |
* and this map does not permit null keys |
97 |
|
*/ |
98 |
< |
Map.Entry<K,V> lowerEntry(K key); |
98 |
> |
Map.Entry<K,V> floorEntry(K key); |
99 |
|
|
100 |
|
/** |
101 |
< |
* Returns the greatest key strictly less than the given key, or |
102 |
< |
* <tt>null</tt> if there is no such key. |
101 |
> |
* Returns the greatest key less than or equal to the given key, |
102 |
> |
* or {@code null} if there is no such key. |
103 |
|
* |
104 |
< |
* @param key the key. |
105 |
< |
* @return the greatest key less than the given |
106 |
< |
* key, or <tt>null</tt> if there is no such key. |
107 |
< |
* @throws ClassCastException if key cannot be compared with the keys |
108 |
< |
* currently in the map. |
109 |
< |
* @throws NullPointerException if key is <tt>null</tt> and this map |
110 |
< |
* does not support <tt>null</tt> keys. |
104 |
> |
* @param key the key |
105 |
> |
* @return the greatest key less than or equal to {@code key}, |
106 |
> |
* or {@code null} if there is no such key |
107 |
> |
* @throws ClassCastException if the specified key cannot be compared |
108 |
> |
* with the keys currently in the map |
109 |
> |
* @throws NullPointerException if the specified key is null |
110 |
> |
* and this map does not permit null keys |
111 |
|
*/ |
112 |
< |
K lowerKey(K key); |
112 |
> |
K floorKey(K key); |
113 |
|
|
114 |
|
/** |
115 |
< |
* Returns a key-value mapping associated with the greatest key |
116 |
< |
* less than or equal to the given key, or <tt>null</tt> if there |
117 |
< |
* is no such entry. |
115 |
> |
* Returns a key-value mapping associated with the least key |
116 |
> |
* greater than or equal to the given key, or {@code null} if |
117 |
> |
* there is no such key. |
118 |
|
* |
119 |
< |
* @param key the key. |
120 |
< |
* @return an Entry associated with floor of given key, or <tt>null</tt> |
121 |
< |
* if there is no such Entry. |
122 |
< |
* @throws ClassCastException if key cannot be compared with the keys |
123 |
< |
* currently in the map. |
124 |
< |
* @throws NullPointerException if key is <tt>null</tt> and this map |
125 |
< |
* does not support <tt>null</tt> keys. |
119 |
> |
* @param key the key |
120 |
> |
* @return an entry with the least key greater than or equal to |
121 |
> |
* {@code key}, or {@code null} if there is no such key |
122 |
> |
* @throws ClassCastException if the specified key cannot be compared |
123 |
> |
* with the keys currently in the map |
124 |
> |
* @throws NullPointerException if the specified key is null |
125 |
> |
* and this map does not permit null keys |
126 |
|
*/ |
127 |
< |
Map.Entry<K,V> floorEntry(K key); |
127 |
> |
Map.Entry<K,V> ceilingEntry(K key); |
128 |
|
|
129 |
|
/** |
130 |
< |
* Returns the greatest key |
131 |
< |
* less than or equal to the given key, or <tt>null</tt> if there |
127 |
< |
* is no such key. |
130 |
> |
* Returns the least key greater than or equal to the given key, |
131 |
> |
* or {@code null} if there is no such key. |
132 |
|
* |
133 |
< |
* @param key the key. |
134 |
< |
* @return the floor of given key, or <tt>null</tt> if there is no |
135 |
< |
* such key. |
136 |
< |
* @throws ClassCastException if key cannot be compared with the keys |
137 |
< |
* currently in the map. |
138 |
< |
* @throws NullPointerException if key is <tt>null</tt> and this map |
139 |
< |
* does not support <tt>null</tt> keys. |
133 |
> |
* @param key the key |
134 |
> |
* @return the least key greater than or equal to {@code key}, |
135 |
> |
* or {@code null} if there is no such key |
136 |
> |
* @throws ClassCastException if the specified key cannot be compared |
137 |
> |
* with the keys currently in the map |
138 |
> |
* @throws NullPointerException if the specified key is null |
139 |
> |
* and this map does not permit null keys |
140 |
|
*/ |
141 |
< |
K floorKey(K key); |
141 |
> |
K ceilingKey(K key); |
142 |
|
|
143 |
|
/** |
144 |
|
* Returns a key-value mapping associated with the least key |
145 |
< |
* strictly greater than the given key, or <tt>null</tt> if there |
146 |
< |
* is no such entry. |
145 |
> |
* strictly greater than the given key, or {@code null} if there |
146 |
> |
* is no such key. |
147 |
|
* |
148 |
< |
* @param key the key. |
149 |
< |
* @return an Entry with least key greater than the given key, or |
150 |
< |
* <tt>null</tt> if there is no such Entry. |
151 |
< |
* @throws ClassCastException if key cannot be compared with the keys |
152 |
< |
* currently in the map. |
153 |
< |
* @throws NullPointerException if key is <tt>null</tt> and this map |
154 |
< |
* does not support <tt>null</tt> keys. |
148 |
> |
* @param key the key |
149 |
> |
* @return an entry with the least key greater than {@code key}, |
150 |
> |
* or {@code null} if there is no such key |
151 |
> |
* @throws ClassCastException if the specified key cannot be compared |
152 |
> |
* with the keys currently in the map |
153 |
> |
* @throws NullPointerException if the specified key is null |
154 |
> |
* and this map does not permit null keys |
155 |
|
*/ |
156 |
|
Map.Entry<K,V> higherEntry(K key); |
157 |
|
|
158 |
|
/** |
159 |
|
* Returns the least key strictly greater than the given key, or |
160 |
< |
* <tt>null</tt> if there is no such key. |
160 |
> |
* {@code null} if there is no such key. |
161 |
|
* |
162 |
< |
* @param key the key. |
163 |
< |
* @return the least key greater than the given key, or |
164 |
< |
* <tt>null</tt> if there is no such key. |
165 |
< |
* @throws ClassCastException if key cannot be compared with the keys |
166 |
< |
* currently in the map. |
167 |
< |
* @throws NullPointerException if key is <tt>null</tt> and this map |
168 |
< |
* does not support <tt>null</tt> keys. |
162 |
> |
* @param key the key |
163 |
> |
* @return the least key greater than {@code key}, |
164 |
> |
* or {@code null} if there is no such key |
165 |
> |
* @throws ClassCastException if the specified key cannot be compared |
166 |
> |
* with the keys currently in the map |
167 |
> |
* @throws NullPointerException if the specified key is null |
168 |
> |
* and this map does not permit null keys |
169 |
|
*/ |
170 |
|
K higherKey(K key); |
171 |
|
|
172 |
|
/** |
173 |
|
* Returns a key-value mapping associated with the least |
174 |
< |
* key in this map, or <tt>null</tt> if the map is empty. |
174 |
> |
* key in this map, or {@code null} if the map is empty. |
175 |
|
* |
176 |
< |
* @return an Entry with least key, or <tt>null</tt> |
177 |
< |
* if the map is empty. |
176 |
> |
* @return an entry with the least key, |
177 |
> |
* or {@code null} if this map is empty |
178 |
|
*/ |
179 |
|
Map.Entry<K,V> firstEntry(); |
180 |
|
|
181 |
|
/** |
182 |
|
* Returns a key-value mapping associated with the greatest |
183 |
< |
* key in this map, or <tt>null</tt> if the map is empty. |
183 |
> |
* key in this map, or {@code null} if the map is empty. |
184 |
|
* |
185 |
< |
* @return an Entry with greatest key, or <tt>null</tt> |
186 |
< |
* if the map is empty. |
185 |
> |
* @return an entry with the greatest key, |
186 |
> |
* or {@code null} if this map is empty |
187 |
|
*/ |
188 |
|
Map.Entry<K,V> lastEntry(); |
189 |
|
|
190 |
|
/** |
191 |
|
* Removes and returns a key-value mapping associated with |
192 |
< |
* the least key in this map, or <tt>null</tt> if the map is empty. |
192 |
> |
* the least key in this map, or {@code null} if the map is empty. |
193 |
|
* |
194 |
< |
* @return the removed first entry of this map, or <tt>null</tt> |
195 |
< |
* if the map is empty. |
194 |
> |
* @return the removed first entry of this map, |
195 |
> |
* or {@code null} if this map is empty |
196 |
|
*/ |
197 |
|
Map.Entry<K,V> pollFirstEntry(); |
198 |
|
|
199 |
|
/** |
200 |
|
* Removes and returns a key-value mapping associated with |
201 |
< |
* the greatest key in this map, or <tt>null</tt> if the map is empty. |
201 |
> |
* the greatest key in this map, or {@code null} if the map is empty. |
202 |
|
* |
203 |
< |
* @return the removed last entry of this map, or <tt>null</tt> |
204 |
< |
* if the map is empty. |
203 |
> |
* @return the removed last entry of this map, |
204 |
> |
* or {@code null} if this map is empty |
205 |
|
*/ |
206 |
|
Map.Entry<K,V> pollLastEntry(); |
207 |
|
|
208 |
|
/** |
209 |
< |
* Returns a set view of the keys contained in this map, in |
210 |
< |
* descending key order. The set is backed by the map, so changes |
211 |
< |
* to the map are reflected in the set, and vice-versa. If the |
212 |
< |
* map is modified while an iteration over the set is in progress |
213 |
< |
* (except through the iterator's own <tt>remove</tt> operation), |
214 |
< |
* the results of the iteration are undefined. The set supports |
215 |
< |
* element removal, which removes the corresponding mapping from |
216 |
< |
* the map, via the <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, |
217 |
< |
* <tt>removeAll</tt> <tt>retainAll</tt>, and <tt>clear</tt> |
218 |
< |
* operations. It does not support the add or <tt>addAll</tt> |
209 |
> |
* Returns a {@link NavigableMap} view of the mappings contained in this |
210 |
> |
* map in descending order. The descending map is backed by this map, so |
211 |
> |
* changes to the map are reflected in the descending map, and vice-versa. |
212 |
> |
* If either map is modified while an iteration over a collection view of |
213 |
> |
* the other map is in progress (except through the iterator's own |
214 |
> |
* {@code remove} operation), the results of the iteration are undefined. |
215 |
> |
* |
216 |
> |
* @return a navigable map view of the mappings contained in this map, |
217 |
> |
* sorted in descending order |
218 |
> |
*/ |
219 |
> |
NavigableMap<K,V> descendingMap(); |
220 |
> |
|
221 |
> |
/** |
222 |
> |
* Returns a navigable set view of the keys contained in this navigable |
223 |
> |
* map. The set is backed by the map, so changes to the map are reflected |
224 |
> |
* in the set, and vice-versa. If the map is modified while an iteration |
225 |
> |
* over the set is in progress (except through the iterator's own |
226 |
> |
* {@code remove} operation), the results of the iteration are undefined. |
227 |
> |
* The set supports element removal, which removes the corresponding |
228 |
> |
* mapping from the map, via the {@code Iterator.remove}, |
229 |
> |
* {@code Set.remove}, {@code removeAll}, {@code retainAll}, and |
230 |
> |
* {@code clear} operations. It does not support the {@code add} or |
231 |
> |
* {@code addAll} operations. |
232 |
> |
* |
233 |
> |
* @return a navigable set view of the keys contained in this navigable map |
234 |
> |
*/ |
235 |
> |
NavigableSet<K> navigableKeySet(); |
236 |
> |
|
237 |
> |
/** |
238 |
> |
* Returns a {@link NavigableSet} view of the keys contained in this map. |
239 |
> |
* The set's iterator returns the keys in descending order. |
240 |
> |
* The set is backed by the map, so changes to the map are |
241 |
> |
* reflected in the set, and vice-versa. If the map is modified |
242 |
> |
* while an iteration over the set is in progress (except through |
243 |
> |
* the iterator's own <tt>remove</tt> operation), the results of |
244 |
> |
* the iteration are undefined. The set supports element removal, |
245 |
> |
* which removes the corresponding mapping from the map, via the |
246 |
> |
* <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, |
247 |
> |
* <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. |
250 |
|
* |
251 |
< |
* @return a set view of the keys contained in this map. |
251 |
> |
* @return a set view of the keys contained in this map, sorted in |
252 |
> |
* descending order |
253 |
|
*/ |
254 |
< |
Set<K> descendingKeySet(); |
254 |
> |
NavigableSet<K> descendingKeySet(); |
255 |
|
|
256 |
|
/** |
257 |
< |
* Returns a set view of the mappings contained in this map, in |
258 |
< |
* descending key order. Each element in the returned set is a |
259 |
< |
* <tt>Map.Entry</tt>. The set is backed by the map, so changes to |
260 |
< |
* the map are reflected in the set, and vice-versa. If the map |
261 |
< |
* is modified while an iteration over the set is in progress |
262 |
< |
* (except through the iterator's own <tt>remove</tt> operation, |
263 |
< |
* or through the <tt>setValue</tt> operation on a map entry |
264 |
< |
* returned by the iterator) the results of the iteration are |
265 |
< |
* undefined. The set supports element removal, which removes the |
266 |
< |
* corresponding mapping from the map, via the |
267 |
< |
* <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, |
268 |
< |
* <tt>removeAll</tt>, <tt>retainAll</tt> and <tt>clear</tt> |
269 |
< |
* operations. It does not support the <tt>add</tt> or |
270 |
< |
* <tt>addAll</tt> operations. |
271 |
< |
* |
272 |
< |
* @return a set view of the mappings contained in this map. |
257 |
> |
* Returns a view of the portion of this map whose keys range from |
258 |
> |
* {@code fromKey} to {@code toKey}. If {@code fromKey} and |
259 |
> |
* {@code toKey} are equal, the returned map is empty unless |
260 |
> |
* {@code fromExclusive} and {@code toExclusive} are both true. The |
261 |
> |
* returned map is backed by this map, so changes in the returned map are |
262 |
> |
* reflected in this map, and vice-versa. The returned map supports all |
263 |
> |
* optional map operations that this map supports. |
264 |
> |
* |
265 |
> |
* <p>The returned map will throw an {@code IllegalArgumentException} |
266 |
> |
* on an attempt to insert a key outside of its range, or to construct a |
267 |
> |
* submap either of whose endpoints lie outside its range. |
268 |
> |
* |
269 |
> |
* @param fromKey low endpoint of the keys in the returned map |
270 |
> |
* @param fromInclusive {@code true} if the low endpoint |
271 |
> |
* is to be included in the returned view |
272 |
> |
* @param toKey high endpoint of the keys in the returned map |
273 |
> |
* @param toInclusive {@code true} if the high endpoint |
274 |
> |
* is to be included in the returned view |
275 |
> |
* @return a view of the portion of this map whose keys range from |
276 |
> |
* {@code fromKey} to {@code toKey} |
277 |
> |
* @throws ClassCastException if {@code fromKey} and {@code toKey} |
278 |
> |
* cannot be compared to one another using this map's comparator |
279 |
> |
* (or, if the map has no comparator, using natural ordering). |
280 |
> |
* Implementations may, but are not required to, throw this |
281 |
> |
* exception if {@code fromKey} or {@code toKey} |
282 |
> |
* cannot be compared to keys currently in the map. |
283 |
> |
* @throws NullPointerException if {@code fromKey} or {@code toKey} |
284 |
> |
* is null and this map does not permit null keys |
285 |
> |
* @throws IllegalArgumentException if {@code fromKey} is greater than |
286 |
> |
* {@code toKey}; or if this map itself has a restricted |
287 |
> |
* range, and {@code fromKey} or {@code toKey} lies |
288 |
> |
* outside the bounds of the range |
289 |
> |
*/ |
290 |
> |
NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, |
291 |
> |
K toKey, boolean toInclusive); |
292 |
> |
|
293 |
> |
/** |
294 |
> |
* Returns a view of the portion of this map whose keys are less than (or |
295 |
> |
* equal to, if {@code inclusive} is true) {@code toKey}. The returned |
296 |
> |
* map is backed by this map, so changes in the returned map are reflected |
297 |
> |
* in this map, and vice-versa. The returned map supports all optional |
298 |
> |
* map operations that this map supports. |
299 |
> |
* |
300 |
> |
* <p>The returned map will throw an {@code IllegalArgumentException} |
301 |
> |
* on an attempt to insert a key outside its range. |
302 |
> |
* |
303 |
> |
* @param toKey high endpoint of the keys in the returned map |
304 |
> |
* @param inclusive {@code true} if the high endpoint |
305 |
> |
* is to be included in the returned view |
306 |
> |
* @return a view of the portion of this map whose keys are less than |
307 |
> |
* (or equal to, if {@code inclusive} is true) {@code toKey} |
308 |
> |
* @throws ClassCastException if {@code toKey} is not compatible |
309 |
> |
* with this map's comparator (or, if the map has no comparator, |
310 |
> |
* if {@code toKey} does not implement {@link Comparable}). |
311 |
> |
* Implementations may, but are not required to, throw this |
312 |
> |
* exception if {@code toKey} cannot be compared to keys |
313 |
> |
* currently in the map. |
314 |
> |
* @throws NullPointerException if {@code toKey} is null |
315 |
> |
* and this map does not permit null keys |
316 |
> |
* @throws IllegalArgumentException if this map itself has a |
317 |
> |
* restricted range, and {@code toKey} lies outside the |
318 |
> |
* bounds of the range |
319 |
> |
*/ |
320 |
> |
NavigableMap<K,V> headMap(K toKey, boolean inclusive); |
321 |
> |
|
322 |
> |
/** |
323 |
> |
* Returns a view of the portion of this map whose keys are greater than (or |
324 |
> |
* equal to, if {@code inclusive} is true) {@code fromKey}. The returned |
325 |
> |
* map is backed by this map, so changes in the returned map are reflected |
326 |
> |
* in this map, and vice-versa. The returned map supports all optional |
327 |
> |
* map operations that this map supports. |
328 |
> |
* |
329 |
> |
* <p>The returned map will throw an {@code IllegalArgumentException} |
330 |
> |
* on an attempt to insert a key outside its range. |
331 |
> |
* |
332 |
> |
* @param fromKey low endpoint of the keys in the returned map |
333 |
> |
* @param inclusive {@code true} if the low endpoint |
334 |
> |
* is to be included in the returned view |
335 |
> |
* @return a view of the portion of this map whose keys are greater than |
336 |
> |
* (or equal to, if {@code inclusive} is true) {@code fromKey} |
337 |
> |
* @throws ClassCastException if {@code fromKey} is not compatible |
338 |
> |
* with this map's comparator (or, if the map has no comparator, |
339 |
> |
* if {@code fromKey} does not implement {@link Comparable}). |
340 |
> |
* Implementations may, but are not required to, throw this |
341 |
> |
* exception if {@code fromKey} cannot be compared to keys |
342 |
> |
* currently in the map. |
343 |
> |
* @throws NullPointerException if {@code fromKey} is null |
344 |
> |
* and this map does not permit null keys |
345 |
> |
* @throws IllegalArgumentException if this map itself has a |
346 |
> |
* restricted range, and {@code fromKey} lies outside the |
347 |
> |
* bounds of the range |
348 |
|
*/ |
349 |
< |
Set<Map.Entry<K, V>> descendingEntrySet(); |
349 |
> |
NavigableMap<K,V> tailMap(K fromKey, boolean inclusive); |
350 |
|
|
351 |
|
/** |
352 |
< |
* Returns a view of the portion of this map whose keys range from |
353 |
< |
* <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive. (If |
244 |
< |
* <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned |
245 |
< |
* navigable map is empty.) The returned navigable map is backed |
246 |
< |
* by this map, so changes in the returned navigable map are |
247 |
< |
* reflected in this map, and vice-versa. |
352 |
> |
* Equivalent to {@code subMap(fromKey, true, toKey, false)} |
353 |
> |
* but with a return type conforming to the {@code SortedMap} interface. |
354 |
|
* |
355 |
< |
* @param fromKey low endpoint (inclusive) of the subMap. |
250 |
< |
* @param toKey high endpoint (exclusive) of the subMap. |
355 |
> |
* <p>{@inheritDoc} |
356 |
|
* |
357 |
< |
* @return a view of the portion of this map whose keys range from |
358 |
< |
* <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive. |
357 |
> |
* @throws ClassCastException {@inheritDoc} |
358 |
> |
* @throws NullPointerException {@inheritDoc} |
359 |
> |
* @throws IllegalArgumentException {@inheritDoc} |
360 |
> |
*/ |
361 |
> |
SortedMap<K,V> subMap(K fromKey, K toKey); |
362 |
> |
|
363 |
> |
/** |
364 |
> |
* Equivalent to {@code headMap(toKey, false)} |
365 |
> |
* but with a return type conforming to the {@code SortedMap} interface. |
366 |
|
* |
367 |
< |
* @throws ClassCastException if <tt>fromKey</tt> and |
256 |
< |
* <tt>toKey</tt> cannot be compared to one another using this |
257 |
< |
* map's comparator (or, if the map has no comparator, using |
258 |
< |
* natural ordering). |
259 |
< |
* @throws IllegalArgumentException if <tt>fromKey</tt> is greater |
260 |
< |
* than <tt>toKey</tt>. |
261 |
< |
* @throws NullPointerException if <tt>fromKey</tt> or |
262 |
< |
* <tt>toKey</tt> is <tt>null</tt> and this map does not support |
263 |
< |
* <tt>null</tt> keys. |
264 |
< |
*/ |
265 |
< |
NavigableMap<K,V> navigableSubMap(K fromKey, K toKey); |
266 |
< |
|
267 |
< |
/** |
268 |
< |
* Returns a view of the portion of this map whose keys are strictly less |
269 |
< |
* than <tt>toKey</tt>. The returned navigable map is backed by this map, so |
270 |
< |
* changes in the returned navigable map are reflected in this map, and |
271 |
< |
* vice-versa. |
272 |
< |
* @param toKey high endpoint (exclusive) of the headMap. |
273 |
< |
* @return a view of the portion of this map whose keys are strictly |
274 |
< |
* less than <tt>toKey</tt>. |
367 |
> |
* <p>{@inheritDoc} |
368 |
|
* |
369 |
< |
* @throws ClassCastException if <tt>toKey</tt> is not compatible |
370 |
< |
* with this map's comparator (or, if the map has no comparator, |
371 |
< |
* if <tt>toKey</tt> does not implement <tt>Comparable</tt>). |
372 |
< |
* @throws NullPointerException if <tt>toKey</tt> is <tt>null</tt> |
373 |
< |
* and this map does not support <tt>null</tt> keys. |
281 |
< |
*/ |
282 |
< |
NavigableMap<K,V> navigableHeadMap(K toKey); |
369 |
> |
* @throws ClassCastException {@inheritDoc} |
370 |
> |
* @throws NullPointerException {@inheritDoc} |
371 |
> |
* @throws IllegalArgumentException {@inheritDoc} |
372 |
> |
*/ |
373 |
> |
SortedMap<K,V> headMap(K toKey); |
374 |
|
|
375 |
|
/** |
376 |
< |
* Returns a view of the portion of this map whose keys are |
377 |
< |
* greater than or equal to <tt>fromKey</tt>. The returned navigable |
378 |
< |
* map is backed by this map, so changes in the returned navigable |
379 |
< |
* map are reflected in this map, and vice-versa. |
380 |
< |
* @param fromKey low endpoint (inclusive) of the tailMap. |
381 |
< |
* @return a view of the portion of this map whose keys are greater |
382 |
< |
* than or equal to <tt>fromKey</tt>. |
383 |
< |
* @throws ClassCastException if <tt>fromKey</tt> is not compatible |
293 |
< |
* with this map's comparator (or, if the map has no comparator, |
294 |
< |
* if <tt>fromKey</tt> does not implement <tt>Comparable</tt>). |
295 |
< |
* @throws NullPointerException if <tt>fromKey</tt> is <tt>null</tt> |
296 |
< |
* and this map does not support <tt>null</tt> keys. |
376 |
> |
* Equivalent to {@code tailMap(fromKey, true)} |
377 |
> |
* but with a return type conforming to the {@code SortedMap} interface. |
378 |
> |
* |
379 |
> |
* <p>{@inheritDoc} |
380 |
> |
* |
381 |
> |
* @throws ClassCastException {@inheritDoc} |
382 |
> |
* @throws NullPointerException {@inheritDoc} |
383 |
> |
* @throws IllegalArgumentException {@inheritDoc} |
384 |
|
*/ |
385 |
< |
NavigableMap<K,V> navigableTailMap(K fromKey); |
385 |
> |
SortedMap<K,V> tailMap(K fromKey); |
386 |
|
} |