diff options
| author | Neil Fuller <nfuller@google.com> | 2018-07-03 18:46:10 +0100 |
|---|---|---|
| committer | Neil Fuller <nfuller@google.com> | 2018-07-04 09:10:55 +0100 |
| commit | 8a1683f0a26370ce8ee006b520aa5a0d668b8fea (patch) | |
| tree | 9cbe3dd506ffd3af2beaa269e4eb28d2d9a265dc /core/java/android/util | |
| parent | 9a936e967760e0d9e7787f0a4642c692c6d5c969 (diff) | |
Track changes in libcore to remove a constructor
Track changes in libcore to remove a constructor + lint
import order changes. Instead of the constructor a utility
method is introduced.
Test: Build / boot
Bug: 111055375
Change-Id: Id683a9d9d6e27d4c8df623dae189da9e74a6d410
Diffstat (limited to 'core/java/android/util')
| -rw-r--r-- | core/java/android/util/IntArray.java | 18 | ||||
| -rw-r--r-- | core/java/android/util/LongArray.java | 14 |
2 files changed, 11 insertions, 21 deletions
diff --git a/core/java/android/util/IntArray.java b/core/java/android/util/IntArray.java index 3617aa7212dc..5a74ec0e52c0 100644 --- a/core/java/android/util/IntArray.java +++ b/core/java/android/util/IntArray.java @@ -18,9 +18,11 @@ package android.util; import com.android.internal.util.ArrayUtils; import com.android.internal.util.Preconditions; -import java.util.Arrays; + import libcore.util.EmptyArray; +import java.util.Arrays; + /** * Implements a growing array of int primitives. * @@ -102,7 +104,7 @@ public class IntArray implements Cloneable { ensureCapacity(1); int rightSegment = mSize - index; mSize++; - checkBounds(index); + ArrayUtils.checkBounds(mSize, index); if (rightSegment != 0) { // Move by 1 all values from the right of 'index' @@ -175,7 +177,7 @@ public class IntArray implements Cloneable { * Returns the value at the specified position in this array. */ public int get(int index) { - checkBounds(index); + ArrayUtils.checkBounds(mSize, index); return mValues[index]; } @@ -183,7 +185,7 @@ public class IntArray implements Cloneable { * Sets the value at the specified position in this array. */ public void set(int index, int value) { - checkBounds(index); + ArrayUtils.checkBounds(mSize, index); mValues[index] = value; } @@ -205,7 +207,7 @@ public class IntArray implements Cloneable { * Removes the value at the specified index from this array. */ public void remove(int index) { - checkBounds(index); + ArrayUtils.checkBounds(mSize, index); System.arraycopy(mValues, index + 1, mValues, index, mSize - index - 1); mSize--; } @@ -223,10 +225,4 @@ public class IntArray implements Cloneable { public int[] toArray() { return Arrays.copyOf(mValues, mSize); } - - private void checkBounds(int index) { - if (index < 0 || mSize <= index) { - throw new ArrayIndexOutOfBoundsException(mSize, index); - } - } } diff --git a/core/java/android/util/LongArray.java b/core/java/android/util/LongArray.java index fa980966802f..5ed1c8c05cba 100644 --- a/core/java/android/util/LongArray.java +++ b/core/java/android/util/LongArray.java @@ -106,7 +106,7 @@ public class LongArray implements Cloneable { ensureCapacity(1); int rightSegment = mSize - index; mSize++; - checkBounds(index); + ArrayUtils.checkBounds(mSize, index); if (rightSegment != 0) { // Move by 1 all values from the right of 'index' @@ -166,7 +166,7 @@ public class LongArray implements Cloneable { * Returns the value at the specified position in this array. */ public long get(int index) { - checkBounds(index); + ArrayUtils.checkBounds(mSize, index); return mValues[index]; } @@ -174,7 +174,7 @@ public class LongArray implements Cloneable { * Sets the value at the specified position in this array. */ public void set(int index, long value) { - checkBounds(index); + ArrayUtils.checkBounds(mSize, index); mValues[index] = value; } @@ -196,7 +196,7 @@ public class LongArray implements Cloneable { * Removes the value at the specified index from this array. */ public void remove(int index) { - checkBounds(index); + ArrayUtils.checkBounds(mSize, index); System.arraycopy(mValues, index + 1, mValues, index, mSize - index - 1); mSize--; } @@ -215,12 +215,6 @@ public class LongArray implements Cloneable { return Arrays.copyOf(mValues, mSize); } - private void checkBounds(int index) { - if (index < 0 || mSize <= index) { - throw new ArrayIndexOutOfBoundsException(mSize, index); - } - } - /** * Test if each element of {@code a} equals corresponding element from {@code b} */ |
