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 |
< |
* subrannge traversals in either direction using <tt>SubMap</tt>. |
29 |
< |
* |
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. |
33 |
> |
* |
34 |
|
* <p>This interface additionally defines methods <tt>firstEntry</tt>, |
35 |
|
* <tt>pollFirstEntry</tt>, <tt>lastEntry</tt>, and |
36 |
|
* <tt>pollLastEntry</tt> that return and/or remove the least and |
43 |
|
* that it is possible to change mappings in the associated map using |
44 |
|
* method <tt>put</tt>. |
45 |
|
* |
46 |
+ |
* <p>This interface is a member of the |
47 |
+ |
* <a href="{@docRoot}/../guide/collections/index.html"> |
48 |
+ |
* Java Collections Framework</a>. |
49 |
+ |
* |
50 |
|
* @author Doug Lea |
51 |
|
* @param <K> the type of keys maintained by this map |
52 |
< |
* @param <V> the type of mapped values |
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. |
60 |
< |
* |
59 |
> |
* no such entry. |
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. |
66 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
67 |
|
* does not support <tt>null</tt> keys. |
68 |
|
*/ |
69 |
< |
public Map.Entry<K,V> ceilingEntry(K key); |
69 |
> |
Map.Entry<K,V> ceilingEntry(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. |
74 |
< |
* |
74 |
> |
* |
75 |
|
* @param key the key. |
76 |
|
* @return the ceiling key, or <tt>null</tt> |
77 |
|
* if there is no such key. |
80 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
81 |
|
* does not support <tt>null</tt> keys. |
82 |
|
*/ |
83 |
< |
public K ceilingKey(K key); |
83 |
> |
K ceilingKey(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. |
89 |
< |
* |
88 |
> |
* such entry. |
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. |
95 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
96 |
|
* does not support <tt>null</tt> keys. |
97 |
|
*/ |
98 |
< |
public Map.Entry<K,V> lowerEntry(K key); |
98 |
> |
Map.Entry<K,V> lowerEntry(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. |
103 |
< |
* |
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. |
109 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
110 |
|
* does not support <tt>null</tt> keys. |
111 |
|
*/ |
112 |
< |
public K lowerKey(K key); |
112 |
> |
K lowerKey(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. |
118 |
< |
* |
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. |
124 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
125 |
|
* does not support <tt>null</tt> keys. |
126 |
|
*/ |
127 |
< |
public Map.Entry<K,V> floorEntry(K key); |
127 |
> |
Map.Entry<K,V> floorEntry(K key); |
128 |
|
|
129 |
|
/** |
130 |
|
* Returns the greatest key |
131 |
|
* less than or equal to the given key, or <tt>null</tt> if there |
132 |
|
* is no such key. |
133 |
< |
* |
133 |
> |
* |
134 |
|
* @param key the key. |
135 |
|
* @return the floor of given key, or <tt>null</tt> if there is no |
136 |
|
* such key. |
139 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
140 |
|
* does not support <tt>null</tt> keys. |
141 |
|
*/ |
142 |
< |
public K floorKey(K key); |
142 |
> |
K floorKey(K key); |
143 |
|
|
144 |
|
/** |
145 |
|
* Returns a key-value mapping associated with the least key |
146 |
|
* strictly greater than the given key, or <tt>null</tt> if there |
147 |
|
* is no such entry. |
148 |
< |
* |
148 |
> |
* |
149 |
|
* @param key the key. |
150 |
|
* @return an Entry with least key greater than the given key, or |
151 |
|
* <tt>null</tt> if there is no such Entry. |
154 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
155 |
|
* does not support <tt>null</tt> keys. |
156 |
|
*/ |
157 |
< |
public Map.Entry<K,V> higherEntry(K key); |
157 |
> |
Map.Entry<K,V> higherEntry(K key); |
158 |
|
|
159 |
|
/** |
160 |
|
* Returns the least key strictly greater than the given key, or |
161 |
|
* <tt>null</tt> if there is no such key. |
162 |
< |
* |
162 |
> |
* |
163 |
|
* @param key the key. |
164 |
|
* @return the least key greater than the given key, or |
165 |
|
* <tt>null</tt> if there is no such key. |
168 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
169 |
|
* does not support <tt>null</tt> keys. |
170 |
|
*/ |
171 |
< |
public K higherKey(K key); |
171 |
> |
K higherKey(K key); |
172 |
|
|
173 |
|
/** |
174 |
|
* Returns a key-value mapping associated with the least |
175 |
|
* key in this map, or <tt>null</tt> if the map is empty. |
176 |
< |
* |
177 |
< |
* @return an Entry with least key, or <tt>null</tt> |
176 |
> |
* |
177 |
> |
* @return an Entry with least key, or <tt>null</tt> |
178 |
|
* if the map is empty. |
179 |
|
*/ |
180 |
< |
public Map.Entry<K,V> firstEntry(); |
180 |
> |
Map.Entry<K,V> firstEntry(); |
181 |
|
|
182 |
|
/** |
183 |
|
* Returns a key-value mapping associated with the greatest |
184 |
|
* key in this map, or <tt>null</tt> if the map is empty. |
185 |
< |
* |
185 |
> |
* |
186 |
|
* @return an Entry with greatest key, or <tt>null</tt> |
187 |
|
* if the map is empty. |
188 |
|
*/ |
189 |
< |
public Map.Entry<K,V> lastEntry(); |
189 |
> |
Map.Entry<K,V> lastEntry(); |
190 |
|
|
191 |
|
/** |
192 |
|
* Removes and returns a key-value mapping associated with |
193 |
|
* the least key in this map, or <tt>null</tt> if the map is empty. |
194 |
< |
* |
194 |
> |
* |
195 |
|
* @return the removed first entry of this map, or <tt>null</tt> |
196 |
|
* if the map is empty. |
197 |
|
*/ |
198 |
< |
public Map.Entry<K,V> pollFirstEntry(); |
198 |
> |
Map.Entry<K,V> pollFirstEntry(); |
199 |
|
|
200 |
|
/** |
201 |
|
* Removes and returns a key-value mapping associated with |
202 |
|
* the greatest key in this map, or <tt>null</tt> if the map is empty. |
203 |
< |
* |
203 |
> |
* |
204 |
|
* @return the removed last entry of this map, or <tt>null</tt> |
205 |
|
* if the map is empty. |
206 |
|
*/ |
207 |
< |
public Map.Entry<K,V> pollLastEntry(); |
207 |
> |
Map.Entry<K,V> pollLastEntry(); |
208 |
|
|
209 |
|
/** |
210 |
|
* Returns a set view of the keys contained in this map, in |
246 |
|
/** |
247 |
|
* Returns a view of the portion of this map whose keys range from |
248 |
|
* <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive. (If |
249 |
< |
* <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned sorted map |
250 |
< |
* is empty.) The returned sorted map is backed by this map, so changes |
251 |
< |
* in the returned sorted map are reflected in this map, and vice-versa. |
252 |
< |
|
249 |
> |
* <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned |
250 |
> |
* navigable map is empty.) The returned navigable map is backed |
251 |
> |
* by this map, so changes in the returned navigable map are |
252 |
> |
* reflected in this map, and vice-versa. |
253 |
> |
* |
254 |
|
* @param fromKey low endpoint (inclusive) of the subMap. |
255 |
|
* @param toKey high endpoint (exclusive) of the subMap. |
256 |
|
* |
267 |
|
* <tt>toKey</tt> is <tt>null</tt> and this map does not support |
268 |
|
* <tt>null</tt> keys. |
269 |
|
*/ |
270 |
< |
public NavigableMap<K,V> subMap(K fromKey, K toKey); |
270 |
> |
NavigableMap<K,V> navigableSubMap(K fromKey, K toKey); |
271 |
|
|
272 |
|
/** |
273 |
|
* Returns a view of the portion of this map whose keys are strictly less |
274 |
< |
* than <tt>toKey</tt>. The returned sorted map is backed by this map, so |
275 |
< |
* changes in the returned sorted map are reflected in this map, and |
276 |
< |
* vice-versa. |
274 |
> |
* than <tt>toKey</tt>. The returned navigable map is backed by this map, so |
275 |
> |
* changes in the returned navigable map are reflected in this map, and |
276 |
> |
* vice-versa. |
277 |
|
* @param toKey high endpoint (exclusive) of the headMap. |
278 |
|
* @return a view of the portion of this map whose keys are strictly |
279 |
|
* less than <tt>toKey</tt>. |
284 |
|
* @throws NullPointerException if <tt>toKey</tt> is <tt>null</tt> |
285 |
|
* and this map does not support <tt>null</tt> keys. |
286 |
|
*/ |
287 |
< |
public NavigableMap<K,V> headMap(K toKey); |
287 |
> |
NavigableMap<K,V> navigableHeadMap(K toKey); |
288 |
|
|
289 |
|
/** |
290 |
|
* Returns a view of the portion of this map whose keys are |
291 |
< |
* greater than or equal to <tt>fromKey</tt>. The returned sorted |
292 |
< |
* map is backed by this map, so changes in the returned sorted |
291 |
> |
* greater than or equal to <tt>fromKey</tt>. The returned navigable |
292 |
> |
* map is backed by this map, so changes in the returned navigable |
293 |
|
* map are reflected in this map, and vice-versa. |
294 |
|
* @param fromKey low endpoint (inclusive) of the tailMap. |
295 |
|
* @return a view of the portion of this map whose keys are greater |
300 |
|
* @throws NullPointerException if <tt>fromKey</tt> is <tt>null</tt> |
301 |
|
* and this map does not support <tt>null</tt> keys. |
302 |
|
*/ |
303 |
< |
public NavigableMap<K,V> tailMap(K fromKey); |
303 |
> |
NavigableMap<K,V> navigableTailMap(K fromKey); |
304 |
|
} |