@CanIgnoreReturnValue
  @Override
  public List<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
    List<V> oldValues = getCopy(key);
    ListIterator<V> keyValues = new ValueForKeyIterator(key);
    Iterator<? extends V> newValues = values.iterator();

    // Replace existing values, if any.
    while (keyValues.hasNext() && newValues.hasNext()) {
      keyValues.next();
      keyValues.set(newValues.next());
    }

    // Remove remaining old values, if any.
    while (keyValues.hasNext()) {
      keyValues.next();
      keyValues.remove();
    }

    // Add remaining new values, if any.
    while (newValues.hasNext()) {
      keyValues.add(newValues.next());
    }

    return oldValues;
  }
@CanIgnoreReturnValue
  @Override
  public List<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
    List<V> oldValues = getCopy(key);
    ListIterator<V> keyValues = new ValueForKeyIterator(key);
    Iterator<? extends V> newValues = values.iterator();

    
    while (keyValues.hasNext() && newValues.hasNext()) {
      keyValues.next();
      keyValues.set(newValues.next());
    }

    
    while (keyValues.hasNext()) {
      keyValues.next();
      keyValues.remove();
    }

    
    while (newValues.hasNext()) {
      keyValues.add(newValues.next());
    }

    return oldValues;
  }
@ CanIgnoreReturnValue @ Override public List < V > replaceValues ( @ Nullable K key , Iterable < ? extends V > values ) { List < V > oldValues = getCopy ( key ) ; ListIterator < V > keyValues = new ValueForKeyIterator ( key ) ; Iterator < ? extends V > newValues = values . iterator ( ) ; // Replace existing values, if any. while ( keyValues . hasNext ( ) && newValues . hasNext ( ) ) { keyValues . next ( ) ; keyValues . set ( newValues . next ( ) ) ; } // Remove remaining old values, if any. while ( keyValues . hasNext ( ) ) { keyValues . next ( ) ; keyValues . remove ( ) ; } // Add remaining new values, if any. while ( newValues . hasNext ( ) ) { keyValues . add ( newValues . next ( ) ) ; } return oldValues ; }
{@inheritDoc}

<p>If any entries for the specified {@code key} already exist in the multimap, their values are
changed in-place without affecting the iteration order.

<p>The returned list is immutable and implements {@link java.util.RandomAccess}.
{ @inheritDoc }