diff options
Diffstat (limited to 'guava/src/com/google/common/collect/ImmutableCollection.java')
-rw-r--r-- | guava/src/com/google/common/collect/ImmutableCollection.java | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/guava/src/com/google/common/collect/ImmutableCollection.java b/guava/src/com/google/common/collect/ImmutableCollection.java index 2aeca97..5fca2aa 100644 --- a/guava/src/com/google/common/collect/ImmutableCollection.java +++ b/guava/src/com/google/common/collect/ImmutableCollection.java @@ -17,7 +17,6 @@ package com.google.common.collect; import com.google.common.annotations.GwtCompatible; -import com.google.common.annotations.VisibleForTesting; import java.io.Serializable; import java.util.Collection; @@ -86,9 +85,7 @@ public abstract class ImmutableCollection<E> * Guaranteed to throw an exception and leave the collection unmodified. * * @throws UnsupportedOperationException always - * @deprecated Unsupported operation. */ - @Deprecated @Override public final boolean add(E e) { throw new UnsupportedOperationException(); @@ -98,9 +95,7 @@ public abstract class ImmutableCollection<E> * Guaranteed to throw an exception and leave the collection unmodified. * * @throws UnsupportedOperationException always - * @deprecated Unsupported operation. */ - @Deprecated @Override public final boolean remove(Object object) { throw new UnsupportedOperationException(); @@ -110,9 +105,7 @@ public abstract class ImmutableCollection<E> * Guaranteed to throw an exception and leave the collection unmodified. * * @throws UnsupportedOperationException always - * @deprecated Unsupported operation. */ - @Deprecated @Override public final boolean addAll(Collection<? extends E> newElements) { throw new UnsupportedOperationException(); @@ -122,9 +115,7 @@ public abstract class ImmutableCollection<E> * Guaranteed to throw an exception and leave the collection unmodified. * * @throws UnsupportedOperationException always - * @deprecated Unsupported operation. */ - @Deprecated @Override public final boolean removeAll(Collection<?> oldElements) { throw new UnsupportedOperationException(); @@ -134,9 +125,7 @@ public abstract class ImmutableCollection<E> * Guaranteed to throw an exception and leave the collection unmodified. * * @throws UnsupportedOperationException always - * @deprecated Unsupported operation. */ - @Deprecated @Override public final boolean retainAll(Collection<?> elementsToKeep) { throw new UnsupportedOperationException(); @@ -146,9 +135,7 @@ public abstract class ImmutableCollection<E> * Guaranteed to throw an exception and leave the collection unmodified. * * @throws UnsupportedOperationException always - * @deprecated Unsupported operation. */ - @Deprecated @Override public final void clear() { throw new UnsupportedOperationException(); @@ -177,7 +164,7 @@ public abstract class ImmutableCollection<E> case 1: return ImmutableList.of(iterator().next()); default: - return new RegularImmutableAsList<E>(this, toArray()); + return new ImmutableAsList<E>(toArray(), this); } } @@ -199,7 +186,7 @@ public abstract class ImmutableCollection<E> } @Override public UnmodifiableIterator<Object> iterator() { - return Iterators.EMPTY_LIST_ITERATOR; + return Iterators.EMPTY_ITERATOR; } private static final Object[] EMPTY_ARRAY = new Object[0]; @@ -285,24 +272,6 @@ public abstract class ImmutableCollection<E> * @since 10.0 */ public abstract static class Builder<E> { - static final int DEFAULT_INITIAL_CAPACITY = 4; - - @VisibleForTesting - static int expandedCapacity(int oldCapacity, int minCapacity) { - if (minCapacity < 0) { - throw new AssertionError("cannot store more than MAX_VALUE elements"); - } - // careful of overflow! - int newCapacity = oldCapacity + (oldCapacity >> 1) + 1; - if (newCapacity < minCapacity) { - newCapacity = Integer.highestOneBit(minCapacity - 1) << 1; - } - if (newCapacity < 0) { - newCapacity = Integer.MAX_VALUE; - // guaranteed to be >= newCapacity - } - return newCapacity; - } Builder() { } |