1499 |
|
* @param m the map whose mappings are to be placed in this map. |
1500 |
|
* @throws ClassCastException if the keys in m are not Comparable, or |
1501 |
|
* are not mutually comparable. |
1502 |
< |
* @throws NullPointerException if the specified map is null. |
1502 |
> |
* @throws NullPointerException if the specified map is <tt>null</tt>. |
1503 |
|
*/ |
1504 |
|
public ConcurrentSkipListMap(Map<? extends K, ? extends V> m) { |
1505 |
|
this.comparator = null; |
1512 |
|
* <tt>SortedMap</tt>, sorted according to the same ordering. |
1513 |
|
* @param m the sorted map whose mappings are to be placed in this map, |
1514 |
|
* and whose comparator is to be used to sort this map. |
1515 |
< |
* @throws NullPointerException if the specified sorted map is null. |
1515 |
> |
* @throws NullPointerException if the specified sorted map is <tt>null</tt>. |
1516 |
|
*/ |
1517 |
|
public ConcurrentSkipListMap(SortedMap<K, ? extends V> m) { |
1518 |
|
this.comparator = m.comparator(); |
2118 |
|
|
2119 |
|
/** |
2120 |
|
* Returns a key-value mapping associated with the least key |
2121 |
< |
* greater than or equal to the given key, or null if there is |
2121 |
> |
* greater than or equal to the given key, or <tt>null</tt> if there is |
2122 |
|
* no such entry. The returned entry does <em>not</em> support |
2123 |
|
* the <tt>Entry.setValue</tt> method. |
2124 |
|
* |
2125 |
|
* @param key the key. |
2126 |
< |
* @return an Entry associated with ceiling of given key, or null |
2126 |
> |
* @return an Entry associated with ceiling of given key, or <tt>null</tt> |
2127 |
|
* if there is no such Entry. |
2128 |
|
* @throws ClassCastException if key cannot be compared with the keys |
2129 |
|
* currently in the map. |
2135 |
|
|
2136 |
|
/** |
2137 |
|
* Returns a key-value mapping associated with the greatest |
2138 |
< |
* key strictly less than the given key, or null if there is no |
2138 |
> |
* key strictly less than the given key, or <tt>null</tt> if there is no |
2139 |
|
* such entry. The returned entry does <em>not</em> support |
2140 |
|
* the <tt>Entry.setValue</tt> method. |
2141 |
|
* |
2142 |
|
* @param key the key. |
2143 |
|
* @return an Entry with greatest key less than the given |
2144 |
< |
* key, or null if there is no such Entry. |
2144 |
> |
* key, or <tt>null</tt> if there is no such Entry. |
2145 |
|
* @throws ClassCastException if key cannot be compared with the keys |
2146 |
|
* currently in the map. |
2147 |
|
* @throws NullPointerException if key is <tt>null</tt>. |
2152 |
|
|
2153 |
|
/** |
2154 |
|
* Returns a key-value mapping associated with the greatest |
2155 |
< |
* key less than or equal to the given key, or null if there is no |
2155 |
> |
* key less than or equal to the given key, or <tt>null</tt> if there is no |
2156 |
|
* such entry. The returned entry does <em>not</em> support |
2157 |
|
* the <tt>Entry.setValue</tt> method. |
2158 |
|
* |
2159 |
|
* @param key the key. |
2160 |
< |
* @return an Entry associated with floor of given key, or null |
2160 |
> |
* @return an Entry associated with floor of given key, or <tt>null</tt> |
2161 |
|
* if there is no such Entry. |
2162 |
|
* @throws ClassCastException if key cannot be compared with the keys |
2163 |
|
* currently in the map. |
2169 |
|
|
2170 |
|
/** |
2171 |
|
* Returns a key-value mapping associated with the least |
2172 |
< |
* key strictly greater than the given key, or null if there is no |
2172 |
> |
* key strictly greater than the given key, or <tt>null</tt> if there is no |
2173 |
|
* such entry. The returned entry does <em>not</em> support |
2174 |
|
* the <tt>Entry.setValue</tt> method. |
2175 |
|
* |
2176 |
|
* @param key the key. |
2177 |
|
* @return an Entry with least key greater than the given key, or |
2178 |
< |
* null if there is no such Entry. |
2178 |
> |
* <tt>null</tt> if there is no such Entry. |
2179 |
|
* @throws ClassCastException if key cannot be compared with the keys |
2180 |
|
* currently in the map. |
2181 |
|
* @throws NullPointerException if key is <tt>null</tt>. |
2186 |
|
|
2187 |
|
/** |
2188 |
|
* Returns a key-value mapping associated with the least |
2189 |
< |
* key in this map, or null if the map is empty. |
2189 |
> |
* key in this map, or <tt>null</tt> if the map is empty. |
2190 |
|
* The returned entry does <em>not</em> support |
2191 |
|
* the <tt>Entry.setValue</tt> method. |
2192 |
|
* |
2193 |
< |
* @return an Entry with least key, or null |
2193 |
> |
* @return an Entry with least key, or <tt>null</tt> |
2194 |
|
* if the map is empty. |
2195 |
|
*/ |
2196 |
|
public Map.Entry<K,V> firstEntry() { |
2206 |
|
|
2207 |
|
/** |
2208 |
|
* Returns a key-value mapping associated with the greatest |
2209 |
< |
* key in this map, or null if the map is empty. |
2209 |
> |
* key in this map, or <tt>null</tt> if the map is empty. |
2210 |
|
* The returned entry does <em>not</em> support |
2211 |
|
* the <tt>Entry.setValue</tt> method. |
2212 |
|
* |
2213 |
< |
* @return an Entry with greatest key, or null |
2213 |
> |
* @return an Entry with greatest key, or <tt>null</tt> |
2214 |
|
* if the map is empty. |
2215 |
|
*/ |
2216 |
|
public Map.Entry<K,V> lastEntry() { |
2226 |
|
|
2227 |
|
/** |
2228 |
|
* Removes and returns a key-value mapping associated with |
2229 |
< |
* the least key in this map, or null if the map is empty. |
2229 |
> |
* the least key in this map, or <tt>null</tt> if the map is empty. |
2230 |
|
* The returned entry does <em>not</em> support |
2231 |
|
* the <tt>Entry.setValue</tt> method. |
2232 |
|
* |
2233 |
< |
* @return the removed first entry of this map, or null |
2233 |
> |
* @return the removed first entry of this map, or <tt>null</tt> |
2234 |
|
* if the map is empty. |
2235 |
|
*/ |
2236 |
|
public Map.Entry<K,V> pollFirstEntry() { |
2239 |
|
|
2240 |
|
/** |
2241 |
|
* Removes and returns a key-value mapping associated with |
2242 |
< |
* the greatest key in this map, or null if the map is empty. |
2242 |
> |
* the greatest key in this map, or <tt>null</tt> if the map is empty. |
2243 |
|
* The returned entry does <em>not</em> support |
2244 |
|
* the <tt>Entry.setValue</tt> method. |
2245 |
|
* |
2246 |
< |
* @return the removed last entry of this map, or null |
2246 |
> |
* @return the removed last entry of this map, or <tt>null</tt> |
2247 |
|
* if the map is empty. |
2248 |
|
*/ |
2249 |
|
public Map.Entry<K,V> pollLastEntry() { |
2278 |
|
|
2279 |
|
/** |
2280 |
|
* Create a submap iterator starting at given least key, or |
2281 |
< |
* first node if least is null, but not greater or equal to |
2282 |
< |
* fence, or end if fence is null. |
2281 |
> |
* first node if least is <tt>null</tt>, but not greater or equal to |
2282 |
> |
* fence, or end if fence is <tt>null</tt>. |
2283 |
|
*/ |
2284 |
|
ConcurrentSkipListMapIterator(K least, K fence) { |
2285 |
|
for (;;) { |
2516 |
|
* @param rel the relation -- OR'ed combination of EQ, LT, GT |
2517 |
|
* @param least minimum allowed key value |
2518 |
|
* @param fence key greater than maximum allowed key value |
2519 |
< |
* @return Entry fitting relation, or null if no such |
2519 |
> |
* @return Entry fitting relation, or <tt>null</tt> if no such |
2520 |
|
*/ |
2521 |
|
SnapshotEntry<K,V> getNear(K kkey, int rel, K least, K fence) { |
2522 |
|
K key = kkey; |
2541 |
|
// Methods expanding out relational operations for submaps |
2542 |
|
|
2543 |
|
/** |
2544 |
< |
* Return ceiling, or first node if key is null |
2544 |
> |
* Return ceiling, or first node if key is <tt>null</tt> |
2545 |
|
*/ |
2546 |
|
Node<K,V> findCeiling(K key) { |
2547 |
|
return (key == null)? findFirst() : findNear(key, GT|EQ); |
2548 |
|
} |
2549 |
|
|
2550 |
|
/** |
2551 |
< |
* Return lower node, or last node if key is null |
2551 |
> |
* Return lower node, or last node if key is <tt>null</tt> |
2552 |
|
*/ |
2553 |
|
Node<K,V> findLower(K key) { |
2554 |
|
return (key == null)? findLast() : findNear(key, LT); |
2779 |
|
|
2780 |
|
/** |
2781 |
|
* Creates a new submap. |
2782 |
< |
* @param least inclusive least value, or null if from start |
2783 |
< |
* @param fence exclusive upper bound or null if to end |
2782 |
> |
* @param least inclusive least value, or <tt>null</tt> if from start |
2783 |
> |
* @param fence exclusive upper bound or <tt>null</tt> if to end |
2784 |
|
* @throws IllegalArgumentException if least and fence nonnull |
2785 |
|
* and least greater than fence |
2786 |
|
*/ |
2833 |
|
|
2834 |
|
/** |
2835 |
|
* Returns least key. Needed by ConcurrentSkipListSet |
2836 |
< |
* @return least key or null if from start |
2836 |
> |
* @return least key or <tt>null</tt> if from start |
2837 |
|
*/ |
2838 |
|
K getLeast() { |
2839 |
|
return least; |
2841 |
|
|
2842 |
|
/** |
2843 |
|
* Returns fence key. Needed by ConcurrentSkipListSet |
2844 |
< |
* @return fence key or null of to end |
2844 |
> |
* @return fence key or <tt>null</tt> of to end |
2845 |
|
*/ |
2846 |
|
K getFence() { |
2847 |
|
return fence; |
2850 |
|
/** |
2851 |
|
* Non-exception throwing version of firstKey needed by |
2852 |
|
* ConcurrentSkipListSubSet |
2853 |
< |
* @return first key, or null if empty |
2853 |
> |
* @return first key, or <tt>null</tt> if empty |
2854 |
|
*/ |
2855 |
|
K lowestKey() { |
2856 |
|
ConcurrentSkipListMap.Node<K,V> n = firstNode(); |
2863 |
|
/** |
2864 |
|
* Non-exception throwing version of highestKey needed by |
2865 |
|
* ConcurrentSkipListSubSet |
2866 |
< |
* @return last key, or null if empty |
2866 |
> |
* @return last key, or <tt>null</tt> if empty |
2867 |
|
*/ |
2868 |
|
K highestKey() { |
2869 |
|
ConcurrentSkipListMap.Node<K,V> n = lastNode(); |
3250 |
|
|
3251 |
|
/** |
3252 |
|
* Returns a key-value mapping associated with the least key |
3253 |
< |
* greater than or equal to the given key, or null if there is |
3253 |
> |
* greater than or equal to the given key, or <tt>null</tt> if there is |
3254 |
|
* no such entry. The returned entry does <em>not</em> support |
3255 |
|
* the <tt>Entry.setValue</tt> method. |
3256 |
|
* |
3257 |
|
* @param key the key. |
3258 |
< |
* @return an Entry associated with ceiling of given key, or null |
3258 |
> |
* @return an Entry associated with ceiling of given key, or <tt>null</tt> |
3259 |
|
* if there is no such Entry. |
3260 |
|
* @throws ClassCastException if key cannot be compared with the keys |
3261 |
|
* currently in the map. |
3267 |
|
|
3268 |
|
/** |
3269 |
|
* Returns a key-value mapping associated with the greatest |
3270 |
< |
* key strictly less than the given key, or null if there is no |
3270 |
> |
* key strictly less than the given key, or <tt>null</tt> if there is no |
3271 |
|
* such entry. The returned entry does <em>not</em> support |
3272 |
|
* the <tt>Entry.setValue</tt> method. |
3273 |
|
* |
3274 |
|
* @param key the key. |
3275 |
|
* @return an Entry with greatest key less than the given |
3276 |
< |
* key, or null if there is no such Entry. |
3276 |
> |
* key, or <tt>null</tt> if there is no such Entry. |
3277 |
|
* @throws ClassCastException if key cannot be compared with the keys |
3278 |
|
* currently in the map. |
3279 |
|
* @throws NullPointerException if key is <tt>null</tt>. |
3284 |
|
|
3285 |
|
/** |
3286 |
|
* Returns a key-value mapping associated with the greatest |
3287 |
< |
* key less than or equal to the given key, or null if there is no |
3287 |
> |
* key less than or equal to the given key, or <tt>null</tt> if there is no |
3288 |
|
* such entry. The returned entry does <em>not</em> support |
3289 |
|
* the <tt>Entry.setValue</tt> method. |
3290 |
|
* |
3291 |
|
* @param key the key. |
3292 |
< |
* @return an Entry associated with floor of given key, or null |
3292 |
> |
* @return an Entry associated with floor of given key, or <tt>null</tt> |
3293 |
|
* if there is no such Entry. |
3294 |
|
* @throws ClassCastException if key cannot be compared with the keys |
3295 |
|
* currently in the map. |
3301 |
|
|
3302 |
|
/** |
3303 |
|
* Returns a key-value mapping associated with the least |
3304 |
< |
* key strictly greater than the given key, or null if there is no |
3304 |
> |
* key strictly greater than the given key, or <tt>null</tt> if there is no |
3305 |
|
* such entry. The returned entry does <em>not</em> support |
3306 |
|
* the <tt>Entry.setValue</tt> method. |
3307 |
|
* |
3308 |
|
* @param key the key. |
3309 |
|
* @return an Entry with least key greater than the given key, or |
3310 |
< |
* null if there is no such Entry. |
3310 |
> |
* <tt>null</tt> if there is no such Entry. |
3311 |
|
* @throws ClassCastException if key cannot be compared with the keys |
3312 |
|
* currently in the map. |
3313 |
|
* @throws NullPointerException if key is <tt>null</tt>. |
3318 |
|
|
3319 |
|
/** |
3320 |
|
* Returns a key-value mapping associated with the least |
3321 |
< |
* key in this map, or null if the map is empty. |
3321 |
> |
* key in this map, or <tt>null</tt> if the map is empty. |
3322 |
|
* The returned entry does <em>not</em> support |
3323 |
|
* the <tt>Entry.setValue</tt> method. |
3324 |
|
* |
3325 |
< |
* @return an Entry with least key, or null |
3325 |
> |
* @return an Entry with least key, or <tt>null</tt> |
3326 |
|
* if the map is empty. |
3327 |
|
*/ |
3328 |
|
public Map.Entry<K,V> firstEntry() { |
3338 |
|
|
3339 |
|
/** |
3340 |
|
* Returns a key-value mapping associated with the greatest |
3341 |
< |
* key in this map, or null if the map is empty. |
3341 |
> |
* key in this map, or <tt>null</tt> if the map is empty. |
3342 |
|
* The returned entry does <em>not</em> support |
3343 |
|
* the <tt>Entry.setValue</tt> method. |
3344 |
|
* |
3345 |
< |
* @return an Entry with greatest key, or null |
3345 |
> |
* @return an Entry with greatest key, or <tt>null</tt> |
3346 |
|
* if the map is empty. |
3347 |
|
*/ |
3348 |
|
public Map.Entry<K,V> lastEntry() { |
3358 |
|
|
3359 |
|
/** |
3360 |
|
* Removes and returns a key-value mapping associated with |
3361 |
< |
* the least key in this map, or null if the map is empty. |
3361 |
> |
* the least key in this map, or <tt>null</tt> if the map is empty. |
3362 |
|
* The returned entry does <em>not</em> support |
3363 |
|
* the <tt>Entry.setValue</tt> method. |
3364 |
|
* |
3365 |
< |
* @return the removed first entry of this map, or null |
3365 |
> |
* @return the removed first entry of this map, or <tt>null</tt> |
3366 |
|
* if the map is empty. |
3367 |
|
*/ |
3368 |
|
public Map.Entry<K,V> pollFirstEntry() { |
3371 |
|
|
3372 |
|
/** |
3373 |
|
* Removes and returns a key-value mapping associated with |
3374 |
< |
* the greatest key in this map, or null if the map is empty. |
3374 |
> |
* the greatest key in this map, or <tt>null</tt> if the map is empty. |
3375 |
|
* The returned entry does <em>not</em> support |
3376 |
|
* the <tt>Entry.setValue</tt> method. |
3377 |
|
* |
3378 |
< |
* @return the removed last entry of this map, or null |
3378 |
> |
* @return the removed last entry of this map, or <tt>null</tt> |
3379 |
|
* if the map is empty. |
3380 |
|
*/ |
3381 |
|
public Map.Entry<K,V> pollLastEntry() { |