From 9c5dfa5c79fff17f96bf977b86c0c9ceb8c3cf9b Mon Sep 17 00:00:00 2001 From: Zoltan Szatmary-Ban Date: Mon, 23 Feb 2015 17:20:20 +0000 Subject: 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 --- core/java/android/util/IntArray.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'core/java/android/util') 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, (-(insertion + * point) - 1). 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); + } } -- cgit v1.1