@Override
  public Collection<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
    Iterator<? extends V> iterator = values.iterator();
    if (!iterator.hasNext()) {
      return removeAll(key);
    }

    // TODO(lowasser): investigate atomic failure?
    Collection<V> collection = getOrCreateCollection(key);
    Collection<V> oldValues = createCollection();
    oldValues.addAll(collection);

    totalSize -= collection.size();
    collection.clear();

    while (iterator.hasNext()) {
      if (collection.add(iterator.next())) {
        totalSize++;
      }
    }

    return unmodifiableCollectionSubclass(oldValues);
  }
@Override
  public Collection<V> replaceValues(@NullableDecl K key, Iterable<? extends V> values) {
    Iterator<? extends V> iterator = values.iterator();
    if (!iterator.hasNext()) {
      return removeAll(key);
    }

    
    Collection<V> collection = getOrCreateCollection(key);
    Collection<V> oldValues = createCollection();
    oldValues.addAll(collection);

    totalSize -= collection.size();
    collection.clear();

    while (iterator.hasNext()) {
      if (collection.add(iterator.next())) {
        totalSize++;
      }
    }

    return unmodifiableCollectionSubclass(oldValues);
  }
@ Override public Collection < V > replaceValues ( @ NullableDecl K key , Iterable < ? extends V > values ) { Iterator < ? extends V > iterator = values . iterator ( ) ; if ( ! iterator . hasNext ( ) ) { return removeAll ( key ) ; } // TODO(lowasser): investigate atomic failure? Collection < V > collection = getOrCreateCollection ( key ) ; Collection < V > oldValues = createCollection ( ) ; oldValues . addAll ( collection ) ; totalSize -= collection . size ( ) ; collection . clear ( ) ; while ( iterator . hasNext ( ) ) { if ( collection . add ( iterator . next ( ) ) ) { totalSize ++ ; } } return unmodifiableCollectionSubclass ( oldValues ) ; }
{@inheritDoc}

<p>The returned collection is immutable.
{ @inheritDoc }