package com.google.common.util.concurrent; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.Lists; import com.google.common.util.concurrent.AggregateFuture; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ abstract class CollectionFuture extends AggregateFuture { @CheckForNull private List> values; abstract C combine(List> list); CollectionFuture(ImmutableCollection> immutableCollection, boolean z) { super(immutableCollection, z, true); List> newArrayListWithCapacity; if (immutableCollection.isEmpty()) { newArrayListWithCapacity = Collections.emptyList(); } else { newArrayListWithCapacity = Lists.newArrayListWithCapacity(immutableCollection.size()); } for (int i = 0; i < immutableCollection.size(); i++) { newArrayListWithCapacity.add(null); } this.values = newArrayListWithCapacity; } @Override // com.google.common.util.concurrent.AggregateFuture final void collectOneValue(int i, @ParametricNullness V v) { List> list = this.values; if (list != null) { list.set(i, new Present<>(v)); } } @Override // com.google.common.util.concurrent.AggregateFuture final void handleAllCompleted() { List> list = this.values; if (list != null) { set(combine(list)); } } @Override // com.google.common.util.concurrent.AggregateFuture void releaseResources(AggregateFuture.ReleaseResourcesReason releaseResourcesReason) { super.releaseResources(releaseResourcesReason); this.values = null; } /* loaded from: classes3.dex */ static final class ListFuture extends CollectionFuture> { /* JADX INFO: Access modifiers changed from: package-private */ public ListFuture(ImmutableCollection> immutableCollection, boolean z) { super(immutableCollection, z); init(); } @Override // com.google.common.util.concurrent.CollectionFuture public List combine(List> list) { ArrayList newArrayListWithCapacity = Lists.newArrayListWithCapacity(list.size()); Iterator> it = list.iterator(); while (it.hasNext()) { Present next = it.next(); newArrayListWithCapacity.add(next != null ? next.value : null); } return Collections.unmodifiableList(newArrayListWithCapacity); } } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class Present { V value; Present(V v) { this.value = v; } } }