diff options
author | Zoltan Szatmary-Ban <szatmz@google.com> | 2015-02-23 17:20:20 +0000 |
---|---|---|
committer | Zoltan Szatmary-Ban <szatmz@google.com> | 2015-03-25 15:53:38 +0000 |
commit | 9c5dfa5c79fff17f96bf977b86c0c9ceb8c3cf9b (patch) | |
tree | ae82308c7b8fb06588dc25038b99e291f71dfcbf /core/java/android/util | |
parent | 1181ed8a43c8364b19f4877ec58c4e2640d7dca8 (diff) | |
download | frameworks_base-9c5dfa5c79fff17f96bf977b86c0c9ceb8c3cf9b.zip frameworks_base-9c5dfa5c79fff17f96bf977b86c0c9ceb8c3cf9b.tar.gz frameworks_base-9c5dfa5c79fff17f96bf977b86c0c9ceb8c3cf9b.tar.bz2 |
Data Usage public API
Added new API consisting of android.app.usage.NetworkUsageManager and
android.app.usage.NetworkUsageStats. Through them data usage on a
network interface can be programmatically queried. Both summary and
details are available.
Bug: 19208876
Change-Id: I0e0c4b37ae23ad1e589d4b0c955b93f28ba4333e
Diffstat (limited to 'core/java/android/util')
-rw-r--r-- | core/java/android/util/IntArray.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/java/android/util/IntArray.java b/core/java/android/util/IntArray.java index e8d3947..9326203 100644 --- a/core/java/android/util/IntArray.java +++ b/core/java/android/util/IntArray.java @@ -18,6 +18,7 @@ package android.util; import com.android.internal.util.ArrayUtils; +import java.util.Arrays; import libcore.util.EmptyArray; /** @@ -78,6 +79,24 @@ public class IntArray implements Cloneable { } /** + * Searches the array for the specified value using the binary search algorithm. The array must + * be sorted (as by the {@link Arrays#sort(int[], int, int)} method) prior to making this call. + * If it is not sorted, the results are undefined. If the range contains multiple elements with + * the specified value, there is no guarantee which one will be found. + * + * @param value The value to search for. + * @return index of the search key, if it is contained in the array; otherwise, <i>(-(insertion + * point) - 1)</i>. The insertion point is defined as the point at which the key would + * be inserted into the array: the index of the first element greater than the key, or + * {@link #size()} if all elements in the array are less than the specified key. + * Note that this guarantees that the return value will be >= 0 if and only if the key + * is found. + */ + public int binarySearch(int value) { + return ContainerHelpers.binarySearch(mValues, mSize, value); + } + + /** * Adds the values in the specified array to this array. */ public void addAll(IntArray values) { @@ -159,4 +178,11 @@ public class IntArray implements Cloneable { public int size() { return mSize; } + + /** + * Returns a new array with the contents of this IntArray. + */ + public int[] toArray() { + return Arrays.copyOf(mValues, mSize); + } } |