| Index: third_party/protobuf/java/core/src/main/java/com/google/protobuf/FloatArrayList.java
|
| diff --git a/third_party/protobuf/java/src/main/java/com/google/protobuf/FloatArrayList.java b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/FloatArrayList.java
|
| similarity index 86%
|
| rename from third_party/protobuf/java/src/main/java/com/google/protobuf/FloatArrayList.java
|
| rename to third_party/protobuf/java/core/src/main/java/com/google/protobuf/FloatArrayList.java
|
| index 033b5eed356d2289539c9f4d2b8c9dbe58a8bc4a..63cb6d77320c2de552f5b849d920ded92800383b 100644
|
| --- a/third_party/protobuf/java/src/main/java/com/google/protobuf/FloatArrayList.java
|
| +++ b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/FloatArrayList.java
|
| @@ -34,7 +34,6 @@ import com.google.protobuf.Internal.FloatList;
|
|
|
| import java.util.Arrays;
|
| import java.util.Collection;
|
| -import java.util.List;
|
| import java.util.RandomAccess;
|
|
|
| /**
|
| @@ -44,8 +43,6 @@ import java.util.RandomAccess;
|
| */
|
| final class FloatArrayList extends AbstractProtobufList<Float> implements FloatList, RandomAccess {
|
|
|
| - private static final int DEFAULT_CAPACITY = 10;
|
| -
|
| private static final FloatArrayList EMPTY_LIST = new FloatArrayList();
|
| static {
|
| EMPTY_LIST.makeImmutable();
|
| @@ -70,32 +67,55 @@ final class FloatArrayList extends AbstractProtobufList<Float> implements FloatL
|
| * Constructs a new mutable {@code FloatArrayList} with default capacity.
|
| */
|
| FloatArrayList() {
|
| - this(DEFAULT_CAPACITY);
|
| - }
|
| -
|
| - /**
|
| - * Constructs a new mutable {@code FloatArrayList} with the provided capacity.
|
| - */
|
| - FloatArrayList(int capacity) {
|
| - array = new float[capacity];
|
| - size = 0;
|
| + this(new float[DEFAULT_CAPACITY], 0);
|
| }
|
|
|
| /**
|
| * Constructs a new mutable {@code FloatArrayList} containing the same elements as {@code other}.
|
| */
|
| - FloatArrayList(List<Float> other) {
|
| - if (other instanceof FloatArrayList) {
|
| - FloatArrayList list = (FloatArrayList) other;
|
| - array = list.array.clone();
|
| - size = list.size;
|
| - } else {
|
| - size = other.size();
|
| - array = new float[size];
|
| - for (int i = 0; i < size; i++) {
|
| - array[i] = other.get(i);
|
| + private FloatArrayList(float[] array, int size) {
|
| + this.array = array;
|
| + this.size = size;
|
| + }
|
| +
|
| + @Override
|
| + public boolean equals(Object o) {
|
| + if (this == o) {
|
| + return true;
|
| + }
|
| + if (!(o instanceof FloatArrayList)) {
|
| + return super.equals(o);
|
| + }
|
| + FloatArrayList other = (FloatArrayList) o;
|
| + if (size != other.size) {
|
| + return false;
|
| + }
|
| +
|
| + final float[] arr = other.array;
|
| + for (int i = 0; i < size; i++) {
|
| + if (array[i] != arr[i]) {
|
| + return false;
|
| }
|
| }
|
| +
|
| + return true;
|
| + }
|
| +
|
| + @Override
|
| + public int hashCode() {
|
| + int result = 1;
|
| + for (int i = 0; i < size; i++) {
|
| + result = (31 * result) + Float.floatToIntBits(array[i]);
|
| + }
|
| + return result;
|
| + }
|
| +
|
| + @Override
|
| + public FloatList mutableCopyWithCapacity(int capacity) {
|
| + if (capacity < size) {
|
| + throw new IllegalArgumentException();
|
| + }
|
| + return new FloatArrayList(Arrays.copyOf(array, capacity), size);
|
| }
|
|
|
| @Override
|
|
|