971 public SortedMap<K,V> tailMap(K fromKey) { |
971 public SortedMap<K,V> tailMap(K fromKey) { |
972 return tailMap(fromKey, true); |
972 return tailMap(fromKey, true); |
973 } |
973 } |
974 |
974 |
975 @Override |
975 @Override |
|
976 public boolean replace(K key, V oldValue, V newValue) { |
|
977 Entry<K,V> p = getEntry(key); |
|
978 if (p!=null && Objects.equals(oldValue, p.value)) { |
|
979 p.value = newValue; |
|
980 return true; |
|
981 } |
|
982 return false; |
|
983 } |
|
984 |
|
985 @Override |
|
986 public V replace(K key, V value) { |
|
987 Entry<K,V> p = getEntry(key); |
|
988 if (p!=null) { |
|
989 V oldValue = p.value; |
|
990 p.value = value; |
|
991 return oldValue; |
|
992 } |
|
993 return null; |
|
994 } |
|
995 |
|
996 @Override |
976 public void forEach(BiConsumer<? super K, ? super V> action) { |
997 public void forEach(BiConsumer<? super K, ? super V> action) { |
977 Objects.requireNonNull(action); |
998 Objects.requireNonNull(action); |
978 int expectedModCount = modCount; |
999 int expectedModCount = modCount; |
979 for (Entry<K, V> e = getFirstEntry(); e != null; e = successor(e)) { |
1000 for (Entry<K, V> e = getFirstEntry(); e != null; e = successor(e)) { |
980 action.accept(e.key, e.value); |
1001 action.accept(e.key, e.value); |