2311 |
|
} |
2312 |
|
} |
2313 |
|
|
2314 |
– |
// Factory methods for iterators needed by ConcurrentSkipListSet etc |
2315 |
– |
|
2316 |
– |
Iterator<K> keyIterator() { |
2317 |
– |
return new KeyIterator(); |
2318 |
– |
} |
2319 |
– |
|
2320 |
– |
Iterator<V> valueIterator() { |
2321 |
– |
return new ValueIterator(); |
2322 |
– |
} |
2323 |
– |
|
2324 |
– |
Iterator<Map.Entry<K,V>> entryIterator() { |
2325 |
– |
return new EntryIterator(); |
2326 |
– |
} |
2327 |
– |
|
2314 |
|
/* ---------------- View Classes -------------- */ |
2315 |
|
|
2316 |
|
/* |
2353 |
|
} |
2354 |
|
public Iterator<K> iterator() { |
2355 |
|
if (m instanceof ConcurrentSkipListMap) |
2356 |
< |
return ((ConcurrentSkipListMap<K,V>)m).keyIterator(); |
2356 |
> |
return ((ConcurrentSkipListMap<K,V>)m).new KeyIterator(); |
2357 |
|
else |
2358 |
< |
return ((ConcurrentSkipListMap.SubMap<K,V>)m).keyIterator(); |
2358 |
> |
return ((SubMap<K,V>)m).new SubMapKeyIterator(); |
2359 |
|
} |
2360 |
|
public boolean equals(Object o) { |
2361 |
|
if (o == this) |
2401 |
|
public NavigableSet<K> descendingSet() { |
2402 |
|
return new KeySet<>(m.descendingMap()); |
2403 |
|
} |
2404 |
< |
@SuppressWarnings("unchecked") |
2404 |
> |
|
2405 |
|
public Spliterator<K> spliterator() { |
2406 |
|
if (m instanceof ConcurrentSkipListMap) |
2407 |
|
return ((ConcurrentSkipListMap<K,V>)m).keySpliterator(); |
2408 |
|
else |
2409 |
< |
return (Spliterator<K>)((SubMap<K,V>)m).keyIterator(); |
2409 |
> |
return ((SubMap<K,V>)m).new SubMapKeyIterator(); |
2410 |
|
} |
2411 |
|
} |
2412 |
|
|
2417 |
|
} |
2418 |
|
public Iterator<V> iterator() { |
2419 |
|
if (m instanceof ConcurrentSkipListMap) |
2420 |
< |
return ((ConcurrentSkipListMap<K,V>)m).valueIterator(); |
2420 |
> |
return ((ConcurrentSkipListMap<K,V>)m).new ValueIterator(); |
2421 |
|
else |
2422 |
< |
return ((SubMap<K,V>)m).valueIterator(); |
2422 |
> |
return ((SubMap<K,V>)m).new SubMapValueIterator(); |
2423 |
|
} |
2424 |
|
public int size() { return m.size(); } |
2425 |
|
public boolean isEmpty() { return m.isEmpty(); } |
2427 |
|
public void clear() { m.clear(); } |
2428 |
|
public Object[] toArray() { return toList(this).toArray(); } |
2429 |
|
public <T> T[] toArray(T[] a) { return toList(this).toArray(a); } |
2430 |
< |
@SuppressWarnings("unchecked") |
2430 |
> |
|
2431 |
|
public Spliterator<V> spliterator() { |
2432 |
|
if (m instanceof ConcurrentSkipListMap) |
2433 |
|
return ((ConcurrentSkipListMap<K,V>)m).valueSpliterator(); |
2434 |
|
else |
2435 |
< |
return (Spliterator<V>)((SubMap<K,V>)m).valueIterator(); |
2435 |
> |
return ((SubMap<K,V>)m).new SubMapValueIterator(); |
2436 |
|
} |
2437 |
|
|
2438 |
|
public boolean removeIf(Predicate<? super V> filter) { |
2440 |
|
if (m instanceof ConcurrentSkipListMap) |
2441 |
|
return ((ConcurrentSkipListMap<K,V>)m).removeValueIf(filter); |
2442 |
|
// else use iterator |
2443 |
< |
Iterator<Map.Entry<K,V>> it = ((SubMap<K,V>)m).entryIterator(); |
2443 |
> |
Iterator<Map.Entry<K,V>> it = |
2444 |
> |
((SubMap<K,V>)m).new SubMapEntryIterator(); |
2445 |
|
boolean removed = false; |
2446 |
|
while (it.hasNext()) { |
2447 |
|
Map.Entry<K,V> e = it.next(); |
2460 |
|
} |
2461 |
|
public Iterator<Map.Entry<K,V>> iterator() { |
2462 |
|
if (m instanceof ConcurrentSkipListMap) |
2463 |
< |
return ((ConcurrentSkipListMap<K,V>)m).entryIterator(); |
2463 |
> |
return ((ConcurrentSkipListMap<K,V>)m).new EntryIterator(); |
2464 |
|
else |
2465 |
< |
return ((SubMap<K,V>)m).entryIterator(); |
2465 |
> |
return ((SubMap<K,V>)m).new SubMapEntryIterator(); |
2466 |
|
} |
2467 |
|
|
2468 |
|
public boolean contains(Object o) { |
2504 |
|
} |
2505 |
|
public Object[] toArray() { return toList(this).toArray(); } |
2506 |
|
public <T> T[] toArray(T[] a) { return toList(this).toArray(a); } |
2507 |
< |
@SuppressWarnings("unchecked") |
2507 |
> |
|
2508 |
|
public Spliterator<Map.Entry<K,V>> spliterator() { |
2509 |
|
if (m instanceof ConcurrentSkipListMap) |
2510 |
|
return ((ConcurrentSkipListMap<K,V>)m).entrySpliterator(); |
2511 |
|
else |
2512 |
< |
return (Spliterator<Map.Entry<K,V>>) |
2526 |
< |
((SubMap<K,V>)m).entryIterator(); |
2512 |
> |
return ((SubMap<K,V>)m).new SubMapEntryIterator(); |
2513 |
|
} |
2514 |
|
public boolean removeIf(Predicate<? super Entry<K,V>> filter) { |
2515 |
|
if (filter == null) throw new NullPointerException(); |
2516 |
|
if (m instanceof ConcurrentSkipListMap) |
2517 |
|
return ((ConcurrentSkipListMap<K,V>)m).removeEntryIf(filter); |
2518 |
|
// else use iterator |
2519 |
< |
Iterator<Map.Entry<K,V>> it = ((SubMap<K,V>)m).entryIterator(); |
2519 |
> |
Iterator<Map.Entry<K,V>> it = |
2520 |
> |
((SubMap<K,V>)m).new SubMapEntryIterator(); |
2521 |
|
boolean removed = false; |
2522 |
|
while (it.hasNext()) { |
2523 |
|
Map.Entry<K,V> e = it.next(); |
3049 |
|
return descendingMap().navigableKeySet(); |
3050 |
|
} |
3051 |
|
|
3065 |
– |
Iterator<K> keyIterator() { |
3066 |
– |
return new SubMapKeyIterator(); |
3067 |
– |
} |
3068 |
– |
|
3069 |
– |
Iterator<V> valueIterator() { |
3070 |
– |
return new SubMapValueIterator(); |
3071 |
– |
} |
3072 |
– |
|
3073 |
– |
Iterator<Map.Entry<K,V>> entryIterator() { |
3074 |
– |
return new SubMapEntryIterator(); |
3075 |
– |
} |
3076 |
– |
|
3052 |
|
/** |
3053 |
|
* Variant of main Iter class to traverse through submaps. |
3054 |
|
* Also serves as back-up Spliterator for views. |