FileDocCategorySizeDatePackage
ContainerHelpers.javaAPI DocAndroid 5.1 API2436Thu Mar 12 22:22:56 GMT 2015android.support.v4.util

ContainerHelpers

public class ContainerHelpers extends Object

Fields Summary
static final int[]
EMPTY_INTS
static final long[]
EMPTY_LONGS
static final Object[]
EMPTY_OBJECTS
Constructors Summary
Methods Summary
static intbinarySearch(int[] array, int size, int value)

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

        while (lo <= hi) {
            int mid = (lo + hi) >>> 1;
            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
    
public static booleanequal(java.lang.Object a, java.lang.Object b)

        return a == b || (a != null && a.equals(b));
    
public static intidealByteArraySize(int need)

        for (int i = 4; i < 32; i++)
            if (need <= (1 << i) - 12)
                return (1 << i) - 12;

        return need;
    
public static intidealIntArraySize(int need)


         
        return idealByteArraySize(need * 4) / 4;
    
public static intidealLongArraySize(int need)

        return idealByteArraySize(need * 8) / 8;