Change to bound check instead of exception trap

pull/796/head
Brett Wooldridge 8 years ago
parent 393ca0a7e6
commit 657de54b48

@ -74,10 +74,10 @@ public final class FastList<T> implements List<T>, RandomAccess, Serializable
@Override @Override
public boolean add(T element) public boolean add(T element)
{ {
try { if (size < elementData.length) {
elementData[size++] = element; elementData[size++] = element;
} }
catch (ArrayIndexOutOfBoundsException e) { else {
// overflow-conscious code // overflow-conscious code
final int oldCapacity = elementData.length; final int oldCapacity = elementData.length;
final int newCapacity = oldCapacity << 1; final int newCapacity = oldCapacity << 1;
@ -332,30 +332,35 @@ public final class FastList<T> implements List<T>, RandomAccess, Serializable
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void forEach(Consumer<? super T> action) public void forEach(Consumer<? super T> action)
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Spliterator<T> spliterator() public Spliterator<T> spliterator()
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean removeIf(Predicate<? super T> filter) public boolean removeIf(Predicate<? super T> filter)
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void replaceAll(UnaryOperator<T> operator) public void replaceAll(UnaryOperator<T> operator)
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void sort(Comparator<? super T> c) public void sort(Comparator<? super T> c)
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

Loading…
Cancel
Save