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>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 |
45 |
|
* |
46 |
|
* @author Doug Lea |
47 |
|
* @param <K> the type of keys maintained by this map |
48 |
< |
* @param <V> the type of mapped values |
48 |
> |
* @param <V> the type of mapped values |
49 |
|
*/ |
50 |
|
public interface NavigableMap<K,V> extends SortedMap<K,V> { |
51 |
|
/** |
52 |
|
* Returns a key-value mapping associated with the least key |
53 |
|
* greater than or equal to the given key, or <tt>null</tt> if there is |
54 |
< |
* no such entry. |
55 |
< |
* |
54 |
> |
* no such entry. |
55 |
> |
* |
56 |
|
* @param key the key. |
57 |
|
* @return an Entry associated with ceiling of given key, or <tt>null</tt> |
58 |
|
* if there is no such Entry. |
61 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
62 |
|
* does not support <tt>null</tt> keys. |
63 |
|
*/ |
64 |
< |
public Map.Entry<K,V> ceilingEntry(K key); |
64 |
> |
Map.Entry<K,V> ceilingEntry(K key); |
65 |
|
|
66 |
|
/** |
67 |
|
* Returns least key greater than or equal to the given key, or |
68 |
|
* <tt>null</tt> if there is no such key. |
69 |
< |
* |
69 |
> |
* |
70 |
|
* @param key the key. |
71 |
|
* @return the ceiling key, or <tt>null</tt> |
72 |
|
* if there is no such key. |
75 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
76 |
|
* does not support <tt>null</tt> keys. |
77 |
|
*/ |
78 |
< |
public K ceilingKey(K key); |
78 |
> |
K ceilingKey(K key); |
79 |
|
|
80 |
|
/** |
81 |
|
* Returns a key-value mapping associated with the greatest |
82 |
|
* key strictly less than the given key, or <tt>null</tt> if there is no |
83 |
< |
* such entry. |
84 |
< |
* |
83 |
> |
* such entry. |
84 |
> |
* |
85 |
|
* @param key the key. |
86 |
|
* @return an Entry with greatest key less than the given |
87 |
|
* key, or <tt>null</tt> if there is no such Entry. |
90 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
91 |
|
* does not support <tt>null</tt> keys. |
92 |
|
*/ |
93 |
< |
public Map.Entry<K,V> lowerEntry(K key); |
93 |
> |
Map.Entry<K,V> lowerEntry(K key); |
94 |
|
|
95 |
|
/** |
96 |
|
* Returns the greatest key strictly less than the given key, or |
97 |
|
* <tt>null</tt> if there is no such key. |
98 |
< |
* |
98 |
> |
* |
99 |
|
* @param key the key. |
100 |
|
* @return the greatest key less than the given |
101 |
|
* key, or <tt>null</tt> if there is no such key. |
104 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
105 |
|
* does not support <tt>null</tt> keys. |
106 |
|
*/ |
107 |
< |
public K lowerKey(K key); |
107 |
> |
K lowerKey(K key); |
108 |
|
|
109 |
|
/** |
110 |
|
* Returns a key-value mapping associated with the greatest key |
111 |
|
* less than or equal to the given key, or <tt>null</tt> if there |
112 |
|
* is no such entry. |
113 |
< |
* |
113 |
> |
* |
114 |
|
* @param key the key. |
115 |
|
* @return an Entry associated with floor of given key, or <tt>null</tt> |
116 |
|
* if there is no such Entry. |
119 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
120 |
|
* does not support <tt>null</tt> keys. |
121 |
|
*/ |
122 |
< |
public Map.Entry<K,V> floorEntry(K key); |
122 |
> |
Map.Entry<K,V> floorEntry(K key); |
123 |
|
|
124 |
|
/** |
125 |
|
* Returns the greatest key |
126 |
|
* less than or equal to the given key, or <tt>null</tt> if there |
127 |
|
* is no such key. |
128 |
< |
* |
128 |
> |
* |
129 |
|
* @param key the key. |
130 |
|
* @return the floor of given key, or <tt>null</tt> if there is no |
131 |
|
* such key. |
134 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
135 |
|
* does not support <tt>null</tt> keys. |
136 |
|
*/ |
137 |
< |
public K floorKey(K key); |
137 |
> |
K floorKey(K key); |
138 |
|
|
139 |
|
/** |
140 |
|
* Returns a key-value mapping associated with the least key |
141 |
|
* strictly greater than the given key, or <tt>null</tt> if there |
142 |
|
* is no such entry. |
143 |
< |
* |
143 |
> |
* |
144 |
|
* @param key the key. |
145 |
|
* @return an Entry with least key greater than the given key, or |
146 |
|
* <tt>null</tt> if there is no such Entry. |
149 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
150 |
|
* does not support <tt>null</tt> keys. |
151 |
|
*/ |
152 |
< |
public Map.Entry<K,V> higherEntry(K key); |
152 |
> |
Map.Entry<K,V> higherEntry(K key); |
153 |
|
|
154 |
|
/** |
155 |
|
* Returns the least key strictly greater than the given key, or |
156 |
|
* <tt>null</tt> if there is no such key. |
157 |
< |
* |
157 |
> |
* |
158 |
|
* @param key the key. |
159 |
|
* @return the least key greater than the given key, or |
160 |
|
* <tt>null</tt> if there is no such key. |
163 |
|
* @throws NullPointerException if key is <tt>null</tt> and this map |
164 |
|
* does not support <tt>null</tt> keys. |
165 |
|
*/ |
166 |
< |
public K higherKey(K key); |
166 |
> |
K higherKey(K key); |
167 |
|
|
168 |
|
/** |
169 |
|
* Returns a key-value mapping associated with the least |
170 |
|
* key in this map, or <tt>null</tt> if the map is empty. |
171 |
< |
* |
172 |
< |
* @return an Entry with least key, or <tt>null</tt> |
171 |
> |
* |
172 |
> |
* @return an Entry with least key, or <tt>null</tt> |
173 |
|
* if the map is empty. |
174 |
|
*/ |
175 |
< |
public Map.Entry<K,V> firstEntry(); |
175 |
> |
Map.Entry<K,V> firstEntry(); |
176 |
|
|
177 |
|
/** |
178 |
|
* Returns a key-value mapping associated with the greatest |
179 |
|
* key in this map, or <tt>null</tt> if the map is empty. |
180 |
< |
* |
180 |
> |
* |
181 |
|
* @return an Entry with greatest key, or <tt>null</tt> |
182 |
|
* if the map is empty. |
183 |
|
*/ |
184 |
< |
public Map.Entry<K,V> lastEntry(); |
184 |
> |
Map.Entry<K,V> lastEntry(); |
185 |
|
|
186 |
|
/** |
187 |
|
* Removes and returns a key-value mapping associated with |
188 |
|
* the least key in this map, or <tt>null</tt> if the map is empty. |
189 |
< |
* |
189 |
> |
* |
190 |
|
* @return the removed first entry of this map, or <tt>null</tt> |
191 |
|
* if the map is empty. |
192 |
|
*/ |
193 |
< |
public Map.Entry<K,V> pollFirstEntry(); |
193 |
> |
Map.Entry<K,V> pollFirstEntry(); |
194 |
|
|
195 |
|
/** |
196 |
|
* Removes and returns a key-value mapping associated with |
197 |
|
* the greatest key in this map, or <tt>null</tt> if the map is empty. |
198 |
< |
* |
198 |
> |
* |
199 |
|
* @return the removed last entry of this map, or <tt>null</tt> |
200 |
|
* if the map is empty. |
201 |
|
*/ |
202 |
< |
public Map.Entry<K,V> pollLastEntry(); |
202 |
> |
Map.Entry<K,V> pollLastEntry(); |
203 |
|
|
204 |
|
/** |
205 |
|
* Returns a set view of the keys contained in this map, in |
241 |
|
/** |
242 |
|
* Returns a view of the portion of this map whose keys range from |
243 |
|
* <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive. (If |
244 |
< |
* <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned sorted map |
245 |
< |
* is empty.) The returned sorted map is backed by this map, so changes |
246 |
< |
* in the returned sorted map are reflected in this map, and vice-versa. |
247 |
< |
|
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. |
248 |
> |
* |
249 |
|
* @param fromKey low endpoint (inclusive) of the subMap. |
250 |
|
* @param toKey high endpoint (exclusive) of the subMap. |
251 |
|
* |
262 |
|
* <tt>toKey</tt> is <tt>null</tt> and this map does not support |
263 |
|
* <tt>null</tt> keys. |
264 |
|
*/ |
265 |
< |
public NavigableMap<K,V> subMap(K fromKey, K toKey); |
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 sorted map is backed by this map, so |
270 |
< |
* changes in the returned sorted map are reflected in this map, and |
271 |
< |
* vice-versa. |
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>. |
279 |
|
* @throws NullPointerException if <tt>toKey</tt> is <tt>null</tt> |
280 |
|
* and this map does not support <tt>null</tt> keys. |
281 |
|
*/ |
282 |
< |
public NavigableMap<K,V> headMap(K toKey); |
282 |
> |
NavigableMap<K,V> navigableHeadMap(K toKey); |
283 |
|
|
284 |
|
/** |
285 |
|
* Returns a view of the portion of this map whose keys are |
286 |
< |
* greater than or equal to <tt>fromKey</tt>. The returned sorted |
287 |
< |
* map is backed by this map, so changes in the returned sorted |
286 |
> |
* greater than or equal to <tt>fromKey</tt>. The returned navigable |
287 |
> |
* map is backed by this map, so changes in the returned navigable |
288 |
|
* map are reflected in this map, and vice-versa. |
289 |
|
* @param fromKey low endpoint (inclusive) of the tailMap. |
290 |
|
* @return a view of the portion of this map whose keys are greater |
295 |
|
* @throws NullPointerException if <tt>fromKey</tt> is <tt>null</tt> |
296 |
|
* and this map does not support <tt>null</tt> keys. |
297 |
|
*/ |
298 |
< |
public NavigableMap<K,V> tailMap(K fromKey); |
298 |
> |
NavigableMap<K,V> navigableTailMap(K fromKey); |
299 |
|
} |