当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtils.idealIntArraySize方法代码示例

本文整理汇总了Java中com.android.internal.util.ArrayUtils.idealIntArraySize方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils.idealIntArraySize方法的具体用法?Java ArrayUtils.idealIntArraySize怎么用?Java ArrayUtils.idealIntArraySize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.internal.util.ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils.idealIntArraySize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: append

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Puts a key/value pair into the array, optimizing for the case where
 * the key is greater than all existing keys in the array.
 */
public void append(int key, boolean value) {
    if (mSize != 0 && key <= mKeys[mSize - 1]) {
        put(key, value);
        return;
    }

    int pos = mSize;
    if (pos >= mKeys.length) {
        int n = ArrayUtils.idealIntArraySize(pos + 1);

        int[] nkeys = new int[n];
        boolean[] nvalues = new boolean[n];

        // Log.e("SparseBooleanArray", "grow " + mKeys.length + " to " + n);
        System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
        System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

        mKeys = nkeys;
        mValues = nvalues;
    }

    mKeys[pos] = key;
    mValues[pos] = value;
    mSize = pos + 1;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:30,代码来源:SparseBooleanArray.java

示例2: append

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Puts a key/value pair into the array, optimizing for the case where
 * the key is greater than all existing keys in the array.
 */
public void append(int key, int value) {
    if (mSize != 0 && key <= mKeys[mSize - 1]) {
        put(key, value);
        return;
    }

    int pos = mSize;
    if (pos >= mKeys.length) {
        int n = ArrayUtils.idealIntArraySize(pos + 1);

        int[] nkeys = new int[n];
        int[] nvalues = new int[n];

        // Log.e("SparseIntArray", "grow " + mKeys.length + " to " + n);
        System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
        System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

        mKeys = nkeys;
        mValues = nvalues;
    }

    mKeys[pos] = key;
    mValues[pos] = value;
    mSize = pos + 1;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:30,代码来源:SparseIntArray.java

示例3: SpannableStringInternal

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
SpannableStringInternal(CharSequence source,
                                      int start, int end) {
    if (start == 0 && end == source.length())
        mText = source.toString();
    else
        mText = source.toString().substring(start, end);

    int initial = ArrayUtils.idealIntArraySize(0);
    mSpans = new Object[initial];
    mSpanData = new int[initial * 3];

    if (source instanceof Spanned) {
        Spanned sp = (Spanned) source;
        Object[] spans = sp.getSpans(start, end, Object.class);

        for (int i = 0; i < spans.length; i++) {
            int st = sp.getSpanStart(spans[i]);
            int en = sp.getSpanEnd(spans[i]);
            int fl = sp.getSpanFlags(spans[i]);

            if (st < start)
                st = start;
            if (en > end)
                en = end;

            setSpan(spans[i], st - start, en - start, fl);
        }
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:30,代码来源:SpannableStringInternal.java

示例4: SparseBooleanArray

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Creates a new SparseBooleanArray containing no mappings that will not
 * require any additional memory allocation to store the specified
 * number of mappings.  If you supply an initial capacity of 0, the
 * sparse array will be initialized with a light-weight representation
 * not requiring any additional array allocations.
 */
public SparseBooleanArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = ContainerHelpers.EMPTY_INTS;
        mValues = ContainerHelpers.EMPTY_BOOLEANS;
    } else {
        initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);
        mKeys = new int[initialCapacity];
        mValues = new boolean[initialCapacity];
    }
    mSize = 0;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:19,代码来源:SparseBooleanArray.java

示例5: put

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Adds a mapping from the specified key to the specified value,
 * replacing the previous mapping from the specified key if there
 * was one.
 */
public void put(int key, boolean value) {
    int i = ContainerHelpers.binarySearch(mKeys, mSize, key);

    if (i >= 0) {
        mValues[i] = value;
    } else {
        i = ~i;

        if (mSize >= mKeys.length) {
            int n = ArrayUtils.idealIntArraySize(mSize + 1);

            int[] nkeys = new int[n];
            boolean[] nvalues = new boolean[n];

            // Log.e("SparseBooleanArray", "grow " + mKeys.length + " to " + n);
            System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
            System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

            mKeys = nkeys;
            mValues = nvalues;
        }

        if (mSize - i != 0) {
            // Log.e("SparseBooleanArray", "move " + (mSize - i));
            System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i);
            System.arraycopy(mValues, i, mValues, i + 1, mSize - i);
        }

        mKeys[i] = key;
        mValues[i] = value;
        mSize++;
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:39,代码来源:SparseBooleanArray.java

示例6: SparseArray

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Creates a new SparseArray containing no mappings that will not
 * require any additional memory allocation to store the specified
 * number of mappings.  If you supply an initial capacity of 0, the
 * sparse array will be initialized with a light-weight representation
 * not requiring any additional array allocations.
 */
public SparseArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = ContainerHelpers.EMPTY_INTS;
        mValues = ContainerHelpers.EMPTY_OBJECTS;
    } else {
        initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);
        mKeys = new int[initialCapacity];
        mValues = new Object[initialCapacity];
    }
    mSize = 0;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:19,代码来源:SparseArray.java

示例7: append

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Puts a key/value pair into the array, optimizing for the case where
 * the key is greater than all existing keys in the array.
 */
public void append(int key, E value) {
    if (mSize != 0 && key <= mKeys[mSize - 1]) {
        put(key, value);
        return;
    }

    if (mGarbage && mSize >= mKeys.length) {
        gc();
    }

    int pos = mSize;
    if (pos >= mKeys.length) {
        int n = ArrayUtils.idealIntArraySize(pos + 1);

        int[] nkeys = new int[n];
        Object[] nvalues = new Object[n];

        // Log.e("SparseArray", "grow " + mKeys.length + " to " + n);
        System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
        System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

        mKeys = nkeys;
        mValues = nvalues;
    }

    mKeys[pos] = key;
    mValues[pos] = value;
    mSize = pos + 1;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:34,代码来源:SparseArray.java

示例8: SparseIntArray

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Creates a new SparseIntArray containing no mappings that will not
 * require any additional memory allocation to store the specified
 * number of mappings.  If you supply an initial capacity of 0, the
 * sparse array will be initialized with a light-weight representation
 * not requiring any additional array allocations.
 */
public SparseIntArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = ContainerHelpers.EMPTY_INTS;
        mValues = ContainerHelpers.EMPTY_INTS;
    } else {
        initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);
        mKeys = new int[initialCapacity];
        mValues = new int[initialCapacity];
    }
    mSize = 0;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:19,代码来源:SparseIntArray.java

示例9: put

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Adds a mapping from the specified key to the specified value,
 * replacing the previous mapping from the specified key if there
 * was one.
 */
public void put(int key, int value) {
    int i = ContainerHelpers.binarySearch(mKeys, mSize, key);

    if (i >= 0) {
        mValues[i] = value;
    } else {
        i = ~i;

        if (mSize >= mKeys.length) {
            int n = ArrayUtils.idealIntArraySize(mSize + 1);

            int[] nkeys = new int[n];
            int[] nvalues = new int[n];

            // Log.e("SparseIntArray", "grow " + mKeys.length + " to " + n);
            System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
            System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

            mKeys = nkeys;
            mValues = nvalues;
        }

        if (mSize - i != 0) {
            // Log.e("SparseIntArray", "move " + (mSize - i));
            System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i);
            System.arraycopy(mValues, i, mValues, i + 1, mSize - i);
        }

        mKeys[i] = key;
        mValues[i] = value;
        mSize++;
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:39,代码来源:SparseIntArray.java

示例10: SparseBooleanArray

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Creates a new SparseBooleanArray containing no mappings that will not
 * require any additional memory allocation to store the specified
 * number of mappings.
 */
public SparseBooleanArray(int initialCapacity) {
    initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);

    mKeys = new int[initialCapacity];
    mValues = new boolean[initialCapacity];
    mSize = 0;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:SparseBooleanArray.java

示例11: put

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Adds a mapping from the specified key to the specified value,
 * replacing the previous mapping from the specified key if there
 * was one.
 */
public void put(int key, boolean value) {
    int i = binarySearch(mKeys, 0, mSize, key);

    if (i >= 0) {
        mValues[i] = value;
    } else {
        i = ~i;

        if (mSize >= mKeys.length) {
            int n = ArrayUtils.idealIntArraySize(mSize + 1);

            int[] nkeys = new int[n];
            boolean[] nvalues = new boolean[n];

            // Log.e("SparseBooleanArray", "grow " + mKeys.length + " to " + n);
            System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
            System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

            mKeys = nkeys;
            mValues = nvalues;
        }

        if (mSize - i != 0) {
            // Log.e("SparseBooleanArray", "move " + (mSize - i));
            System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i);
            System.arraycopy(mValues, i, mValues, i + 1, mSize - i);
        }

        mKeys[i] = key;
        mValues[i] = value;
        mSize++;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:39,代码来源:SparseBooleanArray.java

示例12: SparseArray

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Creates a new SparseArray containing no mappings that will not
 * require any additional memory allocation to store the specified
 * number of mappings.
 */
public SparseArray(int initialCapacity) {
    initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);

    mKeys = new int[initialCapacity];
    mValues = new Object[initialCapacity];
    mSize = 0;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:SparseArray.java

示例13: SparseIntArray

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Creates a new SparseIntArray containing no mappings that will not
 * require any additional memory allocation to store the specified
 * number of mappings.
 */
public SparseIntArray(int initialCapacity) {
    initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);

    mKeys = new int[initialCapacity];
    mValues = new int[initialCapacity];
    mSize = 0;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:SparseIntArray.java

示例14: put

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Adds a mapping from the specified key to the specified value,
 * replacing the previous mapping from the specified key if there
 * was one.
 */
public void put(int key, int value) {
    int i = binarySearch(mKeys, 0, mSize, key);

    if (i >= 0) {
        mValues[i] = value;
    } else {
        i = ~i;

        if (mSize >= mKeys.length) {
            int n = ArrayUtils.idealIntArraySize(mSize + 1);

            int[] nkeys = new int[n];
            int[] nvalues = new int[n];

            // Log.e("SparseIntArray", "grow " + mKeys.length + " to " + n);
            System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
            System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

            mKeys = nkeys;
            mValues = nvalues;
        }

        if (mSize - i != 0) {
            // Log.e("SparseIntArray", "move " + (mSize - i));
            System.arraycopy(mKeys, i, mKeys, i + 1, mSize - i);
            System.arraycopy(mValues, i, mValues, i + 1, mSize - i);
        }

        mKeys[i] = key;
        mValues[i] = value;
        mSize++;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:39,代码来源:SparseIntArray.java

示例15: SpannableStringBuilder

import com.android.internal.util.ArrayUtils; //导入方法依赖的package包/类
/**
 * Create a new SpannableStringBuilder containing a copy of the
 * specified slice of the specified text, including its spans if any.
 */
public SpannableStringBuilder(CharSequence text, int start, int end) {
    int srclen = end - start;

    if (srclen < 0) throw new StringIndexOutOfBoundsException();

    int len = ArrayUtils.idealCharArraySize(srclen + 1);
    mText = new char[len];
    mGapStart = srclen;
    mGapLength = len - srclen;

    TextUtils.getChars(text, start, end, mText, 0);

    mSpanCount = 0;
    int alloc = ArrayUtils.idealIntArraySize(0);
    mSpans = new Object[alloc];
    mSpanStarts = new int[alloc];
    mSpanEnds = new int[alloc];
    mSpanFlags = new int[alloc];

    if (text instanceof Spanned) {
        Spanned sp = (Spanned) text;
        Object[] spans = sp.getSpans(start, end, Object.class);

        for (int i = 0; i < spans.length; i++) {
            if (spans[i] instanceof NoCopySpan) {
                continue;
            }

            int st = sp.getSpanStart(spans[i]) - start;
            int en = sp.getSpanEnd(spans[i]) - start;
            int fl = sp.getSpanFlags(spans[i]);

            if (st < 0)
                st = 0;
            if (st > end - start)
                st = end - start;

            if (en < 0)
                en = 0;
            if (en > end - start)
                en = end - start;

            setSpan(false, spans[i], st, en, fl);
        }
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:51,代码来源:SpannableStringBuilder.java


注:本文中的com.android.internal.util.ArrayUtils.idealIntArraySize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。