583 |
|
* support the <tt>Map.Entry.setValue</tt> method. |
584 |
|
*/ |
585 |
|
static class SnapshotEntry<K,V> implements Map.Entry<K,V> { |
586 |
< |
private final K key; |
587 |
< |
private final V value; |
586 |
> |
private final K key; |
587 |
> |
private final V value; |
588 |
|
|
589 |
|
/** |
590 |
|
* Creates a new entry representing the given key and value. |
592 |
|
* @param value the value |
593 |
|
*/ |
594 |
|
SnapshotEntry(K key, V value) { |
595 |
< |
this.key = key; |
596 |
< |
this.value = value; |
597 |
< |
} |
598 |
< |
|
599 |
< |
/** |
600 |
< |
* Returns the key corresponding to this entry. |
601 |
< |
* |
602 |
< |
* @return the key corresponding to this entry. |
603 |
< |
*/ |
595 |
> |
this.key = key; |
596 |
> |
this.value = value; |
597 |
> |
} |
598 |
> |
|
599 |
> |
/** |
600 |
> |
* Returns the key corresponding to this entry. |
601 |
> |
* |
602 |
> |
* @return the key corresponding to this entry. |
603 |
> |
*/ |
604 |
|
public K getKey() { |
605 |
|
return key; |
606 |
|
} |
607 |
|
|
608 |
< |
/** |
609 |
< |
* Returns the value corresponding to this entry. |
610 |
< |
* |
611 |
< |
* @return the value corresponding to this entry. |
612 |
< |
*/ |
608 |
> |
/** |
609 |
> |
* Returns the value corresponding to this entry. |
610 |
> |
* |
611 |
> |
* @return the value corresponding to this entry. |
612 |
> |
*/ |
613 |
|
public V getValue() { |
614 |
< |
return value; |
614 |
> |
return value; |
615 |
|
} |
616 |
|
|
617 |
< |
/** |
618 |
< |
* Always fails, throwing <tt>UnsupportedOperationException</tt>. |
619 |
< |
* @throws UnsupportedOperationException always. |
617 |
> |
/** |
618 |
> |
* Always fails, throwing <tt>UnsupportedOperationException</tt>. |
619 |
> |
* @throws UnsupportedOperationException always. |
620 |
|
*/ |
621 |
|
public V setValue(V value) { |
622 |
|
throw new UnsupportedOperationException(); |
649 |
|
* @return a String representation of this entry. |
650 |
|
*/ |
651 |
|
public String toString() { |
652 |
< |
return getKey() + "=" + getValue(); |
652 |
> |
return getKey() + "=" + getValue(); |
653 |
|
} |
654 |
|
} |
655 |
|
|
1847 |
|
* |
1848 |
|
* @param value value whose presence in this Map is to be tested. |
1849 |
|
* @return <tt>true</tt> if a mapping to <tt>value</tt> exists; |
1850 |
< |
* <tt>false</tt> otherwise. |
1850 |
> |
* <tt>false</tt> otherwise. |
1851 |
|
* @throws NullPointerException if the value is <tt>null</tt>. |
1852 |
|
*/ |
1853 |
|
public boolean containsValue(Object value) { |
2056 |
|
* @return <tt>true</tt> if the specified object is equal to this map. |
2057 |
|
*/ |
2058 |
|
public boolean equals(Object o) { |
2059 |
< |
if (o == this) |
2060 |
< |
return true; |
2061 |
< |
if (!(o instanceof Map)) |
2062 |
< |
return false; |
2063 |
< |
Map<K,V> t = (Map<K,V>) o; |
2059 |
> |
if (o == this) |
2060 |
> |
return true; |
2061 |
> |
if (!(o instanceof Map)) |
2062 |
> |
return false; |
2063 |
> |
Map<K,V> t = (Map<K,V>) o; |
2064 |
|
try { |
2065 |
|
return (containsAllMappings(this, t) && |
2066 |
|
containsAllMappings(t, this)); |
2067 |
< |
} catch(ClassCastException unused) { |
2067 |
> |
} catch (ClassCastException unused) { |
2068 |
|
return false; |
2069 |
< |
} catch(NullPointerException unused) { |
2069 |
> |
} catch (NullPointerException unused) { |
2070 |
|
return false; |
2071 |
|
} |
2072 |
|
} |
2525 |
|
Node<K,V> last; |
2526 |
|
/** the next node to return from next(); */ |
2527 |
|
Node<K,V> next; |
2528 |
< |
/** Cache of next value field to maintain weak consistency */ |
2529 |
< |
Object nextValue; |
2528 |
> |
/** Cache of next value field to maintain weak consistency */ |
2529 |
> |
Object nextValue; |
2530 |
|
|
2531 |
|
Iter() {} |
2532 |
|
|
2537 |
|
/** initialize ascending iterator for entire range */ |
2538 |
|
final void initAscending() { |
2539 |
|
for (;;) { |
2540 |
< |
next = findFirst(); |
2540 |
> |
next = findFirst(); |
2541 |
|
if (next == null) |
2542 |
|
break; |
2543 |
|
nextValue = next.value; |
2553 |
|
*/ |
2554 |
|
final void initAscending(K least, K fence) { |
2555 |
|
for (;;) { |
2556 |
< |
next = findCeiling(least); |
2556 |
> |
next = findCeiling(least); |
2557 |
|
if (next == null) |
2558 |
|
break; |
2559 |
|
nextValue = next.value; |
2571 |
|
if ((last = next) == null) |
2572 |
|
throw new NoSuchElementException(); |
2573 |
|
for (;;) { |
2574 |
< |
next = next.next; |
2574 |
> |
next = next.next; |
2575 |
|
if (next == null) |
2576 |
|
break; |
2577 |
|
nextValue = next.value; |
2587 |
|
if ((last = next) == null) |
2588 |
|
throw new NoSuchElementException(); |
2589 |
|
for (;;) { |
2590 |
< |
next = next.next; |
2590 |
> |
next = next.next; |
2591 |
|
if (next == null) |
2592 |
|
break; |
2593 |
|
nextValue = next.value; |
2604 |
|
/** initialize descending iterator for entire range */ |
2605 |
|
final void initDescending() { |
2606 |
|
for (;;) { |
2607 |
< |
next = findLast(); |
2607 |
> |
next = findLast(); |
2608 |
|
if (next == null) |
2609 |
|
break; |
2610 |
|
nextValue = next.value; |
2621 |
|
*/ |
2622 |
|
final void initDescending(K least, K fence) { |
2623 |
|
for (;;) { |
2624 |
< |
next = findLower(fence); |
2624 |
> |
next = findLower(fence); |
2625 |
|
if (next == null) |
2626 |
|
break; |
2627 |
|
nextValue = next.value; |
2641 |
|
throw new NoSuchElementException(); |
2642 |
|
K k = last.key; |
2643 |
|
for (;;) { |
2644 |
< |
next = findNear(k, LT); |
2644 |
> |
next = findNear(k, LT); |
2645 |
|
if (next == null) |
2646 |
|
break; |
2647 |
|
nextValue = next.value; |
2658 |
|
throw new NoSuchElementException(); |
2659 |
|
K k = last.key; |
2660 |
|
for (;;) { |
2661 |
< |
next = findNear(k, LT); |
2661 |
> |
next = findNear(k, LT); |
2662 |
|
if (next == null) |
2663 |
|
break; |
2664 |
|
nextValue = next.value; |
2781 |
|
Object v = lastValue; |
2782 |
|
if (last == null || v == null) |
2783 |
|
throw new IllegalStateException(); |
2784 |
< |
return (V)v; |
2784 |
> |
return (V)v; |
2785 |
|
} |
2786 |
|
|
2787 |
|
public V setValue(V value) { |
2810 |
|
// If not acting as entry, just use default. |
2811 |
|
if (last == null) |
2812 |
|
return super.toString(); |
2813 |
< |
return getKey() + "=" + getValue(); |
2813 |
> |
return getKey() + "=" + getValue(); |
2814 |
|
} |
2815 |
|
} |
2816 |
|
|