FileDocCategorySizeDatePackage
ContainerHelpers.javaAPI DocAndroid 5.1 API1754Thu Mar 12 22:22:10 GMT 2015android.util

ContainerHelpers

public class ContainerHelpers extends Object

Fields Summary
Constructors Summary
Methods Summary
static intbinarySearch(int[] array, int size, int value)

        int lo = 0;
        int hi = size - 1;

        while (lo <= hi) {
            final int mid = (lo + hi) >>> 1;
            final int midVal = array[mid];

            if (midVal < value) {
                lo = mid + 1;
            } else if (midVal > value) {
                hi = mid - 1;
            } else {
                return mid;  // value found
            }
        }
        return ~lo;  // value not present
    
static intbinarySearch(long[] array, int size, long value)

        int lo = 0;
        int hi = size - 1;

        while (lo <= hi) {
            final int mid = (lo + hi) >>> 1;
            final long midVal = array[mid];

            if (midVal < value) {
                lo = mid + 1;
            } else if (midVal > value) {
                hi = mid - 1;
            } else {
                return mid;  // value found
            }
        }
        return ~lo;  // value not present