2004 |
|
* @throws NullPointerException if <tt>fromKey</tt> or <tt>toKey</tt> is null |
2005 |
|
* @throws IllegalArgumentException {@inheritDoc} |
2006 |
|
*/ |
2007 |
< |
public ConcurrentNavigableMap<K,V> navigableSubMap(K fromKey, |
2008 |
< |
boolean fromInclusive, |
2009 |
< |
K toKey, |
2010 |
< |
boolean toInclusive) { |
2007 |
> |
public ConcurrentNavigableMap<K,V> subMap(K fromKey, |
2008 |
> |
boolean fromInclusive, |
2009 |
> |
K toKey, |
2010 |
> |
boolean toInclusive) { |
2011 |
|
if (fromKey == null || toKey == null) |
2012 |
|
throw new NullPointerException(); |
2013 |
|
return new SubMap<K,V> |
2019 |
|
* @throws NullPointerException if <tt>toKey</tt> is null |
2020 |
|
* @throws IllegalArgumentException {@inheritDoc} |
2021 |
|
*/ |
2022 |
< |
public ConcurrentNavigableMap<K,V> navigableHeadMap(K toKey, |
2023 |
< |
boolean inclusive) { |
2022 |
> |
public ConcurrentNavigableMap<K,V> headMap(K toKey, |
2023 |
> |
boolean inclusive) { |
2024 |
|
if (toKey == null) |
2025 |
|
throw new NullPointerException(); |
2026 |
|
return new SubMap<K,V> |
2032 |
|
* @throws NullPointerException if <tt>fromKey</tt> is null |
2033 |
|
* @throws IllegalArgumentException {@inheritDoc} |
2034 |
|
*/ |
2035 |
< |
public ConcurrentNavigableMap<K,V> navigableTailMap(K fromKey, |
2036 |
< |
boolean inclusive) { |
2035 |
> |
public ConcurrentNavigableMap<K,V> tailMap(K fromKey, |
2036 |
> |
boolean inclusive) { |
2037 |
|
if (fromKey == null) |
2038 |
|
throw new NullPointerException(); |
2039 |
|
return new SubMap<K,V> |
2046 |
|
* @throws IllegalArgumentException {@inheritDoc} |
2047 |
|
*/ |
2048 |
|
public ConcurrentNavigableMap<K,V> subMap(K fromKey, K toKey) { |
2049 |
< |
return navigableSubMap(fromKey, true, toKey, false); |
2049 |
> |
return subMap(fromKey, true, toKey, false); |
2050 |
|
} |
2051 |
|
|
2052 |
|
/** |
2055 |
|
* @throws IllegalArgumentException {@inheritDoc} |
2056 |
|
*/ |
2057 |
|
public ConcurrentNavigableMap<K,V> headMap(K toKey) { |
2058 |
< |
return navigableHeadMap(toKey, false); |
2058 |
> |
return headMap(toKey, false); |
2059 |
|
} |
2060 |
|
|
2061 |
|
/** |
2064 |
|
* @throws IllegalArgumentException {@inheritDoc} |
2065 |
|
*/ |
2066 |
|
public ConcurrentNavigableMap<K,V> tailMap(K fromKey) { |
2067 |
< |
return navigableTailMap(fromKey, true); |
2067 |
> |
return tailMap(fromKey, true); |
2068 |
|
} |
2069 |
|
|
2070 |
|
/* ---------------- Relational operations -------------- */ |
2363 |
|
public Iterator<E> descendingIterator() { |
2364 |
|
return descendingSet().iterator(); |
2365 |
|
} |
2366 |
< |
public NavigableSet<E> navigableSubSet(E fromElement, |
2367 |
< |
boolean fromInclusive, |
2368 |
< |
E toElement, |
2369 |
< |
boolean toInclusive) { |
2366 |
> |
public NavigableSet<E> subSet(E fromElement, |
2367 |
> |
boolean fromInclusive, |
2368 |
> |
E toElement, |
2369 |
> |
boolean toInclusive) { |
2370 |
|
return new ConcurrentSkipListSet<E> |
2371 |
< |
(m.navigableSubMap(fromElement, fromInclusive, |
2372 |
< |
toElement, toInclusive)); |
2371 |
> |
(m.subMap(fromElement, fromInclusive, |
2372 |
> |
toElement, toInclusive)); |
2373 |
|
} |
2374 |
< |
public NavigableSet<E> navigableHeadSet(E toElement, boolean inclusive) { |
2375 |
< |
return new ConcurrentSkipListSet<E>(m.navigableHeadMap(toElement, inclusive)); |
2374 |
> |
public NavigableSet<E> headSet(E toElement, boolean inclusive) { |
2375 |
> |
return new ConcurrentSkipListSet<E>(m.headMap(toElement, inclusive)); |
2376 |
|
} |
2377 |
< |
public NavigableSet<E> navigableTailSet(E fromElement, boolean inclusive) { |
2378 |
< |
return new ConcurrentSkipListSet<E>(m.navigableTailMap(fromElement, inclusive)); |
2377 |
> |
public NavigableSet<E> tailSet(E fromElement, boolean inclusive) { |
2378 |
> |
return new ConcurrentSkipListSet<E>(m.tailMap(fromElement, inclusive)); |
2379 |
|
} |
2380 |
|
public SortedSet<E> subSet(E fromElement, E toElement) { |
2381 |
< |
return navigableSubSet(fromElement, true, toElement, false); |
2381 |
> |
return subSet(fromElement, true, toElement, false); |
2382 |
|
} |
2383 |
|
public SortedSet<E> headSet(E toElement) { |
2384 |
< |
return navigableHeadSet(toElement, false); |
2384 |
> |
return headSet(toElement, false); |
2385 |
|
} |
2386 |
|
public SortedSet<E> tailSet(E fromElement) { |
2387 |
< |
return navigableTailSet(fromElement, true); |
2387 |
> |
return tailSet(fromElement, true); |
2388 |
|
} |
2389 |
|
public NavigableSet<E> descendingSet() { |
2390 |
|
return new ConcurrentSkipListSet(m.descendingMap()); |
2428 |
|
else |
2429 |
|
return ((SubMap<K1,V1>)m).entryIterator(); |
2430 |
|
} |
2431 |
< |
|
2431 |
> |
|
2432 |
|
public boolean contains(Object o) { |
2433 |
|
if (!(o instanceof Map.Entry)) |
2434 |
|
return false; |
2441 |
|
return false; |
2442 |
|
Map.Entry<K1,V1> e = (Map.Entry<K1,V1>)o; |
2443 |
|
return m.remove(e.getKey(), |
2444 |
< |
e.getValue()); |
2444 |
> |
e.getValue()); |
2445 |
|
} |
2446 |
|
public boolean isEmpty() { |
2447 |
|
return m.isEmpty(); |
2508 |
|
K fromKey, boolean fromInclusive, |
2509 |
|
K toKey, boolean toInclusive, |
2510 |
|
boolean isDescending) { |
2511 |
< |
if (fromKey != null && toKey != null && |
2511 |
> |
if (fromKey != null && toKey != null && |
2512 |
|
map.compare(fromKey, toKey) > 0) |
2513 |
|
throw new IllegalArgumentException("inconsistent range"); |
2514 |
|
this.m = map; |
2602 |
|
return n.key; |
2603 |
|
else |
2604 |
|
throw new NoSuchElementException(); |
2605 |
< |
} |
2605 |
> |
} |
2606 |
|
|
2607 |
|
/** |
2608 |
|
* Returns highest absolute key (ignoring directonality) |
2822 |
|
else |
2823 |
|
return Collections.reverseOrder(cmp); |
2824 |
|
} |
2825 |
< |
|
2825 |
> |
|
2826 |
|
/** |
2827 |
|
* Utility to create submaps, where given bounds override |
2828 |
|
* unbounded(null) ones and/or are checked against bounded ones. |
2829 |
|
*/ |
2830 |
< |
private SubMap<K,V> newSubMap(K fromKey, |
2831 |
< |
boolean fromInclusive, |
2832 |
< |
K toKey, |
2830 |
> |
private SubMap<K,V> newSubMap(K fromKey, |
2831 |
> |
boolean fromInclusive, |
2832 |
> |
K toKey, |
2833 |
|
boolean toInclusive) { |
2834 |
|
if (isDescending) { // flip senses |
2835 |
< |
K tk = fromKey; |
2836 |
< |
fromKey = toKey; |
2835 |
> |
K tk = fromKey; |
2836 |
> |
fromKey = toKey; |
2837 |
|
toKey = tk; |
2838 |
< |
boolean ti = fromInclusive; |
2839 |
< |
fromInclusive = toInclusive; |
2838 |
> |
boolean ti = fromInclusive; |
2839 |
> |
fromInclusive = toInclusive; |
2840 |
|
toInclusive = ti; |
2841 |
|
} |
2842 |
|
if (lo != null) { |
2861 |
|
throw new IllegalArgumentException("key out of range"); |
2862 |
|
} |
2863 |
|
} |
2864 |
< |
return new SubMap<K,V>(m, fromKey, fromInclusive, |
2864 |
> |
return new SubMap<K,V>(m, fromKey, fromInclusive, |
2865 |
|
toKey, toInclusive, isDescending); |
2866 |
|
} |
2867 |
|
|
2868 |
< |
public SubMap<K,V> navigableSubMap(K fromKey, |
2869 |
< |
boolean fromInclusive, |
2870 |
< |
K toKey, |
2871 |
< |
boolean toInclusive) { |
2868 |
> |
public SubMap<K,V> subMap(K fromKey, |
2869 |
> |
boolean fromInclusive, |
2870 |
> |
K toKey, |
2871 |
> |
boolean toInclusive) { |
2872 |
|
if (fromKey == null || toKey == null) |
2873 |
|
throw new NullPointerException(); |
2874 |
|
return newSubMap(fromKey, fromInclusive, toKey, toInclusive); |
2875 |
|
} |
2876 |
< |
|
2877 |
< |
public SubMap<K,V> navigableHeadMap(K toKey, |
2878 |
< |
boolean inclusive) { |
2876 |
> |
|
2877 |
> |
public SubMap<K,V> headMap(K toKey, |
2878 |
> |
boolean inclusive) { |
2879 |
|
if (toKey == null) |
2880 |
|
throw new NullPointerException(); |
2881 |
|
return newSubMap(null, false, toKey, inclusive); |
2882 |
|
} |
2883 |
< |
|
2884 |
< |
public SubMap<K,V> navigableTailMap(K fromKey, |
2885 |
< |
boolean inclusive) { |
2883 |
> |
|
2884 |
> |
public SubMap<K,V> tailMap(K fromKey, |
2885 |
> |
boolean inclusive) { |
2886 |
|
if (fromKey == null) |
2887 |
|
throw new NullPointerException(); |
2888 |
|
return newSubMap(fromKey, inclusive, null, false); |
2889 |
|
} |
2890 |
|
|
2891 |
|
public SubMap<K,V> subMap(K fromKey, K toKey) { |
2892 |
< |
return navigableSubMap(fromKey, true, toKey, false); |
2892 |
> |
return subMap(fromKey, true, toKey, false); |
2893 |
|
} |
2894 |
|
|
2895 |
|
public SubMap<K,V> headMap(K toKey) { |
2896 |
< |
return navigableHeadMap(toKey, false); |
2896 |
> |
return headMap(toKey, false); |
2897 |
|
} |
2898 |
|
|
2899 |
|
public SubMap<K,V> tailMap(K fromKey) { |
2900 |
< |
return navigableTailMap(fromKey, true); |
2900 |
> |
return tailMap(fromKey, true); |
2901 |
|
} |
2902 |
|
|
2903 |
|
public SubMap<K,V> descendingMap() { |
2904 |
< |
return new SubMap<K,V>(m, lo, loInclusive, |
2904 |
> |
return new SubMap<K,V>(m, lo, loInclusive, |
2905 |
|
hi, hiInclusive, !isDescending); |
2906 |
|
} |
2907 |
|
|
3012 |
|
/** Cache of next value field to maintain weak consistency */ |
3013 |
|
Object nextValue; |
3014 |
|
|
3015 |
< |
SubMapIter() { |
3015 |
> |
SubMapIter() { |
3016 |
|
for (;;) { |
3017 |
|
next = isDescending? hiNode() : loNode(); |
3018 |
|
if (next == null) |