Merge changes from topic "am-8e5146ce-8d9c-4779-ae0e-dfd45eb1f559"
* changes:
[automerger] Remove use of @hide and RestrictTo in ArraySet. am: 1d6b134dfe
Remove use of @hide and RestrictTo in ArraySet.
diff --git a/compat/src/main/java/android/support/v4/util/ArraySet.java b/compat/src/main/java/android/support/v4/util/ArraySet.java
index ab080fa..a9a8806 100644
--- a/compat/src/main/java/android/support/v4/util/ArraySet.java
+++ b/compat/src/main/java/android/support/v4/util/ArraySet.java
@@ -16,9 +16,6 @@
package android.support.v4.util;
-import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP;
-
-import android.support.annotation.RestrictTo;
import android.util.Log;
import java.lang.reflect.Array;
@@ -74,7 +71,6 @@
static Object[] sTwiceBaseCache;
static int sTwiceBaseCacheSize;
- final boolean mIdentityHashCode;
int[] mHashes;
Object[] mArray;
int mSize;
@@ -238,19 +234,13 @@
* will grow once items are added to it.
*/
public ArraySet() {
- this(0, false);
+ this(0);
}
/**
* Create a new ArraySet with a given initial capacity.
*/
public ArraySet(int capacity) {
- this(capacity, false);
- }
-
- /** {@hide} */
- public ArraySet(int capacity, boolean identityHashCode) {
- mIdentityHashCode = identityHashCode;
if (capacity == 0) {
mHashes = INT;
mArray = OBJECT;
@@ -270,14 +260,6 @@
}
}
- /** {@hide} */
- public ArraySet(Collection<E> set) {
- this();
- if (set != null) {
- addAll(set);
- }
- }
-
/**
* Make the array map empty. All storage is released.
*/
@@ -326,8 +308,7 @@
* @return Returns the index of the value if it exists, else a negative integer.
*/
public int indexOf(Object key) {
- return key == null ? indexOfNull()
- : indexOf(key, mIdentityHashCode ? System.identityHashCode(key) : key.hashCode());
+ return key == null ? indexOfNull() : indexOf(key, key.hashCode());
}
/**
@@ -364,7 +345,7 @@
hash = 0;
index = indexOfNull();
} else {
- hash = mIdentityHashCode ? System.identityHashCode(value) : value.hashCode();
+ hash = value.hashCode();
index = indexOf(value, hash);
}
if (index >= 0) {
@@ -406,36 +387,6 @@
}
/**
- * Special fast path for appending items to the end of the array without validation.
- * The array must already be large enough to contain the item.
- * @hide
- */
- @RestrictTo(LIBRARY_GROUP)
- public void append(E value) {
- final int index = mSize;
- final int hash = value == null ? 0
- : (mIdentityHashCode ? System.identityHashCode(value) : value.hashCode());
- if (index >= mHashes.length) {
- throw new IllegalStateException("Array is full");
- }
- if (index > 0 && mHashes[index - 1] > hash) {
- // Cannot optimize since it would break the sorted order - fallback to add()
- if (DEBUG) {
- RuntimeException e = new RuntimeException("here");
- e.fillInStackTrace();
- Log.w(TAG, "New hash " + hash
- + " is before end of array hash " + mHashes[index - 1]
- + " at index " + index, e);
- }
- add(value);
- return;
- }
- mSize = index + 1;
- mHashes[index] = hash;
- mArray[index] = value;
- }
-
- /**
* Perform a {@link #add(Object)} of all values in <var>array</var>
* @param array The array whose contents are to be retrieved.
*/