diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2016-06-28 00:42:23 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-06-28 00:42:24 +0000 |
| commit | b2cd9c95bf5fdfb8a1ff85c0f8f9c66738dca463 (patch) | |
| tree | 2edfd01f3a3e9ceb9466902aef98e7b64d29ce9b /core/java/android/util/ArraySet.java | |
| parent | a39d3806511d7ada54fcc9e4d73a0693e8014545 (diff) | |
| parent | ddb948896ca7059161e09d0063b3332352772c0a (diff) | |
Merge "Mark app pending intents in notification extras" into nyc-dev
Diffstat (limited to 'core/java/android/util/ArraySet.java')
| -rw-r--r-- | core/java/android/util/ArraySet.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/java/android/util/ArraySet.java b/core/java/android/util/ArraySet.java index 9e9314fba4c4..d39e91fd98b2 100644 --- a/core/java/android/util/ArraySet.java +++ b/core/java/android/util/ArraySet.java @@ -390,6 +390,32 @@ public final class ArraySet<E> implements Collection<E>, Set<E> { } /** + * 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 + */ + 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) { + 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. */ |
