code: @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);
    }
docs: {@inheritDoc}
  
  <p>The returned collection is immutable.