1175 |
|
findFirst(); // retry |
1176 |
|
clearIndexToFirst(); |
1177 |
|
return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, (V)v); |
1178 |
< |
} |
1178 |
> |
} |
1179 |
|
} |
1180 |
|
|
1181 |
|
/** |
1852 |
|
* @return <tt>true</tt> if the specified object is equal to this map |
1853 |
|
*/ |
1854 |
|
public boolean equals(Object o) { |
1855 |
< |
if (o == this) |
1856 |
< |
return true; |
1857 |
< |
if (!(o instanceof Map)) |
1858 |
< |
return false; |
1859 |
< |
Map<?,?> m = (Map<?,?>) o; |
1855 |
> |
if (o == this) |
1856 |
> |
return true; |
1857 |
> |
if (!(o instanceof Map)) |
1858 |
> |
return false; |
1859 |
> |
Map<?,?> m = (Map<?,?>) o; |
1860 |
|
try { |
1861 |
< |
for (Map.Entry<K,V> e : this.entrySet()) |
1862 |
< |
if (! e.getValue().equals(m.get(e.getKey()))) |
1861 |
> |
for (Map.Entry<K,V> e : this.entrySet()) |
1862 |
> |
if (! e.getValue().equals(m.get(e.getKey()))) |
1863 |
|
return false; |
1864 |
< |
for (Map.Entry<?,?> e : m.entrySet()) { |
1864 |
> |
for (Map.Entry<?,?> e : m.entrySet()) { |
1865 |
|
Object k = e.getKey(); |
1866 |
|
Object v = e.getValue(); |
1867 |
< |
if (k == null || v == null || !v.equals(get(k))) |
1867 |
> |
if (k == null || v == null || !v.equals(get(k))) |
1868 |
|
return false; |
1869 |
|
} |
1870 |
|
return true; |
2208 |
|
Node<K,V> lastReturned; |
2209 |
|
/** the next node to return from next(); */ |
2210 |
|
Node<K,V> next; |
2211 |
< |
/** Cache of next value field to maintain weak consistency */ |
2212 |
< |
V nextValue; |
2211 |
> |
/** Cache of next value field to maintain weak consistency */ |
2212 |
> |
V nextValue; |
2213 |
|
|
2214 |
|
/** Initializes ascending iterator for entire range. */ |
2215 |
|
Iter() { |
2216 |
|
for (;;) { |
2217 |
< |
next = findFirst(); |
2217 |
> |
next = findFirst(); |
2218 |
|
if (next == null) |
2219 |
|
break; |
2220 |
|
Object x = next.value; |
2221 |
|
if (x != null && x != next) { |
2222 |
< |
nextValue = (V) x; |
2222 |
> |
nextValue = (V) x; |
2223 |
|
break; |
2224 |
< |
} |
2224 |
> |
} |
2225 |
|
} |
2226 |
|
} |
2227 |
|
|
2233 |
|
final void advance() { |
2234 |
|
if (next == null) |
2235 |
|
throw new NoSuchElementException(); |
2236 |
< |
lastReturned = next; |
2236 |
> |
lastReturned = next; |
2237 |
|
for (;;) { |
2238 |
< |
next = next.next; |
2238 |
> |
next = next.next; |
2239 |
|
if (next == null) |
2240 |
|
break; |
2241 |
|
Object x = next.value; |
2242 |
|
if (x != null && x != next) { |
2243 |
< |
nextValue = (V) x; |
2243 |
> |
nextValue = (V) x; |
2244 |
|
break; |
2245 |
< |
} |
2245 |
> |
} |
2246 |
|
} |
2247 |
|
} |
2248 |
|
|
2253 |
|
// It would not be worth all of the overhead to directly |
2254 |
|
// unlink from here. Using remove is fast enough. |
2255 |
|
ConcurrentSkipListMap.this.remove(l.key); |
2256 |
< |
lastReturned = null; |
2256 |
> |
lastReturned = null; |
2257 |
|
} |
2258 |
|
|
2259 |
|
} |
2306 |
|
*/ |
2307 |
|
|
2308 |
|
static final <E> List<E> toList(Collection<E> c) { |
2309 |
< |
// Using size() here would be a pessimization. |
2310 |
< |
List<E> list = new ArrayList<E>(); |
2311 |
< |
for (E e : c) |
2312 |
< |
list.add(e); |
2313 |
< |
return list; |
2309 |
> |
// Using size() here would be a pessimization. |
2310 |
> |
List<E> list = new ArrayList<E>(); |
2311 |
> |
for (E e : c) |
2312 |
> |
list.add(e); |
2313 |
> |
return list; |
2314 |
|
} |
2315 |
|
|
2316 |
|
static final class KeySet<E> extends AbstractSet<E> implements NavigableSet<E> { |
2356 |
|
return false; |
2357 |
|
} |
2358 |
|
} |
2359 |
< |
public Object[] toArray() { return toList(this).toArray(); } |
2360 |
< |
public <T> T[] toArray(T[] a) { return toList(this).toArray(a); } |
2359 |
> |
public Object[] toArray() { return toList(this).toArray(); } |
2360 |
> |
public <T> T[] toArray(T[] a) { return toList(this).toArray(a); } |
2361 |
|
public Iterator<E> descendingIterator() { |
2362 |
|
return descendingSet().iterator(); |
2363 |
|
} |
2412 |
|
public void clear() { |
2413 |
|
m.clear(); |
2414 |
|
} |
2415 |
< |
public Object[] toArray() { return toList(this).toArray(); } |
2416 |
< |
public <T> T[] toArray(T[] a) { return toList(this).toArray(a); } |
2415 |
> |
public Object[] toArray() { return toList(this).toArray(); } |
2416 |
> |
public <T> T[] toArray(T[] a) { return toList(this).toArray(a); } |
2417 |
|
} |
2418 |
|
|
2419 |
|
static final class EntrySet<K1,V1> extends AbstractSet<Map.Entry<K1,V1>> { |
2466 |
|
return false; |
2467 |
|
} |
2468 |
|
} |
2469 |
< |
public Object[] toArray() { return toList(this).toArray(); } |
2470 |
< |
public <T> T[] toArray(T[] a) { return toList(this).toArray(a); } |
2469 |
> |
public Object[] toArray() { return toList(this).toArray(); } |
2470 |
> |
public <T> T[] toArray(T[] a) { return toList(this).toArray(a); } |
2471 |
|
} |
2472 |
|
|
2473 |
|
/** |
2821 |
|
|
2822 |
|
public Comparator<? super K> comparator() { |
2823 |
|
Comparator<? super K> cmp = m.comparator(); |
2824 |
< |
if (isDescending) |
2825 |
< |
return Collections.reverseOrder(cmp); |
2826 |
< |
else |
2827 |
< |
return cmp; |
2824 |
> |
if (isDescending) |
2825 |
> |
return Collections.reverseOrder(cmp); |
2826 |
> |
else |
2827 |
> |
return cmp; |
2828 |
|
} |
2829 |
|
|
2830 |
|
/** |
3021 |
|
next = isDescending ? hiNode() : loNode(); |
3022 |
|
if (next == null) |
3023 |
|
break; |
3024 |
< |
Object x = next.value; |
3024 |
> |
Object x = next.value; |
3025 |
|
if (x != null && x != next) { |
3026 |
< |
if (! inBounds(next.key)) |
3026 |
> |
if (! inBounds(next.key)) |
3027 |
|
next = null; |
3028 |
< |
else |
3029 |
< |
nextValue = (V) x; |
3028 |
> |
else |
3029 |
> |
nextValue = (V) x; |
3030 |
|
break; |
3031 |
|
} |
3032 |
|
} |
3039 |
|
final void advance() { |
3040 |
|
if (next == null) |
3041 |
|
throw new NoSuchElementException(); |
3042 |
< |
lastReturned = next; |
3042 |
> |
lastReturned = next; |
3043 |
|
if (isDescending) |
3044 |
|
descend(); |
3045 |
|
else |
3051 |
|
next = next.next; |
3052 |
|
if (next == null) |
3053 |
|
break; |
3054 |
< |
Object x = next.value; |
3054 |
> |
Object x = next.value; |
3055 |
|
if (x != null && x != next) { |
3056 |
|
if (tooHigh(next.key)) |
3057 |
|
next = null; |
3058 |
|
else |
3059 |
< |
nextValue = (V) x; |
3059 |
> |
nextValue = (V) x; |
3060 |
|
break; |
3061 |
|
} |
3062 |
|
} |
3067 |
|
next = m.findNear(lastReturned.key, LT); |
3068 |
|
if (next == null) |
3069 |
|
break; |
3070 |
< |
Object x = next.value; |
3070 |
> |
Object x = next.value; |
3071 |
|
if (x != null && x != next) { |
3072 |
|
if (tooLow(next.key)) |
3073 |
|
next = null; |
3074 |
< |
else |
3074 |
> |
else |
3075 |
|
nextValue = (V) x; |
3076 |
|
break; |
3077 |
|
} |
3083 |
|
if (l == null) |
3084 |
|
throw new IllegalStateException(); |
3085 |
|
m.remove(l.key); |
3086 |
< |
lastReturned = null; |
3086 |
> |
lastReturned = null; |
3087 |
|
} |
3088 |
|
|
3089 |
|
} |