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