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


Java ArrayUtils.idealIntArraySize方法代码示例

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


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

示例1: append

import org.andengine.util.adt.array.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, float 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];
        float[] nvalues = new float[n];

        // Log.e("SparseFloatArray", "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:mediamonks,项目名称:tilt-game-android,代码行数:30,代码来源:SparseFloatArray.java

示例2: append

import org.andengine.util.adt.array.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, byte 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];
        byte[] nvalues = new byte[n];

        // Log.e("SparseByteArray", "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:ArturVasilov,项目名称:AndroidCourses,代码行数:30,代码来源:SparseByteArray.java

示例3: append

import org.andengine.util.adt.array.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, long 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];
        long[] nvalues = new long[n];

        // Log.e("SparseLongArray", "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:ArturVasilov,项目名称:AndroidCourses,代码行数:30,代码来源:SparseLongArray.java

示例4: append

import org.andengine.util.adt.array.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, char 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];
        char[] nvalues = new char[n];

        // Log.e("SparseCharArray", "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:ArturVasilov,项目名称:AndroidCourses,代码行数:30,代码来源:SparseCharArray.java

示例5: append

import org.andengine.util.adt.array.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, double 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];
        double[] nvalues = new double[n];

        // Log.e("SparseDoubleArray", "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:delight-im,项目名称:NationSoccer,代码行数:30,代码来源:SparseDoubleArray.java

示例6: put

import org.andengine.util.adt.array.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, char 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];
            char[] nvalues = new char[n];

            // Log.e("SparseCharArray", "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("SparseCharArray", "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:ArturVasilov,项目名称:AndroidCourses,代码行数:39,代码来源:SparseCharArray.java

示例7: put

import org.andengine.util.adt.array.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, byte 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];
            byte[] nvalues = new byte[n];

            // Log.e("SparseByteArray", "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("SparseByteArray", "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:ArturVasilov,项目名称:AndroidCourses,代码行数:39,代码来源:SparseByteArray.java

示例8: LongSparseArray

import org.andengine.util.adt.array.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 LongSparseArray(int initialCapacity) {
    initialCapacity = ArrayUtils.idealIntArraySize(initialCapacity);

    mKeys = new long[initialCapacity];
    mValues = new Object[initialCapacity];
    mSize = 0;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:13,代码来源:LongSparseArray.java

示例9: append

import org.andengine.util.adt.array.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(long 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);

        long[] nkeys = new long[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:ArturVasilov,项目名称:AndroidCourses,代码行数:34,代码来源:LongSparseArray.java

示例10: SparseLongArray

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

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

示例11: put

import org.andengine.util.adt.array.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, long 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];
            long[] nvalues = new long[n];

            // Log.e("SparseLongArray", "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("SparseLongArray", "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:ArturVasilov,项目名称:AndroidCourses,代码行数:39,代码来源:SparseLongArray.java

示例12: SparseByteArray

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

    mKeys = new int[initialCapacity];
    mValues = new byte[initialCapacity];
    mSize = 0;
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:13,代码来源:SparseByteArray.java

示例13: SparseFloatArray

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

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

示例14: SparseDoubleArray

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

    mKeys = new int[initialCapacity];
    mValues = new double[initialCapacity];
    mSize = 0;
}
 
开发者ID:delight-im,项目名称:NationSoccer,代码行数:13,代码来源:SparseDoubleArray.java

示例15: put

import org.andengine.util.adt.array.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, double 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];
            double[] nvalues = new double[n];

            // Log.e("SparseDoubleArray", "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("SparseDoubleArray", "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:delight-im,项目名称:NationSoccer,代码行数:39,代码来源:SparseDoubleArray.java


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