• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ArrayUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: resizeFor

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
private void resizeFor(int size) {
    final int oldLength = mText.length;
    final int newLength = ArrayUtils.idealCharArraySize(size + 1);
    final int delta = newLength - oldLength;
    if (delta == 0) return;

    char[] newText = new char[newLength];
    System.arraycopy(mText, 0, newText, 0, mGapStart);
    final int after = oldLength - (mGapStart + mGapLength);
    System.arraycopy(mText, oldLength - after, newText, newLength - after, after);
    mText = newText;

    mGapLength += delta;
    if (mGapLength < 1)
        new Exception("mGapLength < 1").printStackTrace();

    for (int i = 0; i < mSpanCount; i++) {
        if (mSpanStarts[i] > mGapStart) mSpanStarts[i] += delta;
        if (mSpanEnds[i] > mGapStart) mSpanEnds[i] += delta;
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:22,代码来源:SpannableStringBuilder.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, 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


示例3: 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


示例4: hookSDcardPermission

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
public static void hookSDcardPermission()
{
	final Class<?> pms = XposedHelpers.findClass("com.android.server.pm.PackageManagerService", null);

	XposedHelpers.findAndHookMethod(pms, "readPermission", "org.xmlpull.v1.XmlPullParser", "java.lang.String", new XC_MethodHook()
	{
		protected void afterHookedMethod(MethodHookParam param) throws Throwable
		{
			String permission = (String) param.args[1];

			if (permission.equals("android.permission.WRITE_EXTERNAL_STORAGE"))
			{
				Class<?> process = XposedHelpers.findClass("android.os.Process", null);
				int gid = (Integer) XposedHelpers.callStaticMethod(process, "getGidForName", "media_rw");
				Object mSettings = XposedHelpers.getObjectField(param.thisObject, "mSettings");
				Object mPermissions = XposedHelpers.getObjectField(mSettings, "mPermissions");
				Object bp = XposedHelpers.callMethod(mPermissions, "get", permission);
				int[] bp_gids = (int[]) XposedHelpers.getObjectField(bp, "gids");
				XposedHelpers.setObjectField(bp, "gids", ArrayUtils.appendInt(bp_gids, gid));
			}
		}
	});
}
 
开发者ID:Falseclock,项目名称:HtcOneTweaker,代码行数:24,代码来源:Android.java


示例5: LongSparseArray

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
/**
 * Creates a new LongSparseArray 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 LongSparseArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = EmptyArray.LONG;
        mValues = EmptyArray.OBJECT;
    } else {
        mKeys = ArrayUtils.newUnpaddedLongArray(initialCapacity);
        mValues = ArrayUtils.newUnpaddedObjectArray(initialCapacity);
    }
    mSize = 0;
}
 
开发者ID:doppllib,项目名称:core-doppl,代码行数:18,代码来源:LongSparseArray.java


示例6: LongSparseLongArray

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
/**
 * Creates a new SparseLongArray 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 LongSparseLongArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = EmptyArray.LONG;
        mValues = EmptyArray.LONG;
    } else {
        mKeys = ArrayUtils.newUnpaddedLongArray(initialCapacity);
        mValues = new long[mKeys.length];
    }
    mSize = 0;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:18,代码来源:LongSparseLongArray.java


示例7: SparseLongArray

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
/**
 * Creates a new SparseLongArray 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 SparseLongArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = EmptyArray.INT;
        mValues = EmptyArray.LONG;
    } else {
        mValues = ArrayUtils.newUnpaddedLongArray(initialCapacity);
        mKeys = new int[mValues.length];
    }
    mSize = 0;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:18,代码来源:SparseLongArray.java


示例8: 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 = EmptyArray.INT;
        mValues = EmptyArray.BOOLEAN;
    } else {
        mKeys = ArrayUtils.newUnpaddedIntArray(initialCapacity);
        mValues = new boolean[mKeys.length];
    }
    mSize = 0;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:18,代码来源:SparseBooleanArray.java


示例9: 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 = EmptyArray.INT;
        mValues = EmptyArray.OBJECT;
    } else {
        mValues = ArrayUtils.newUnpaddedObjectArray(initialCapacity);
        mKeys = new int[mValues.length];
    }
    mSize = 0;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:18,代码来源:SparseArray.java


示例10: LongArray

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
/**
 * Creates an empty LongArray with the specified initial capacity.
 */
public LongArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mValues = EmptyArray.LONG;
    } else {
        mValues = ArrayUtils.newUnpaddedLongArray(initialCapacity);
    }
    mSize = 0;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:12,代码来源:LongArray.java


示例11: ensureCapacity

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
/**
 * Ensures capacity to append at least <code>count</code> values.
 */
private void ensureCapacity(int count) {
    final int currentSize = mSize;
    final int minCapacity = currentSize + count;
    if (minCapacity >= mValues.length) {
        final int targetCap = currentSize + (currentSize < (MIN_CAPACITY_INCREMENT / 2) ?
                MIN_CAPACITY_INCREMENT : currentSize >> 1);
        final int newCapacity = targetCap > minCapacity ? targetCap : minCapacity;
        final long[] newValues = ArrayUtils.newUnpaddedLongArray(newCapacity);
        System.arraycopy(mValues, 0, newValues, 0, currentSize);
        mValues = newValues;
    }
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:16,代码来源:LongArray.java


示例12: 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 = EmptyArray.INT;
        mValues = EmptyArray.INT;
    } else {
        mKeys = ArrayUtils.newUnpaddedIntArray(initialCapacity);
        mValues = new int[mKeys.length];
    }
    mSize = 0;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:18,代码来源:SparseIntArray.java


示例13: obtain

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
static char[] obtain(int len) {
    char[] buf;

    synchronized (sLock) {
        buf = sTemp;
        sTemp = null;
    }

    if (buf == null || buf.length < len)
        buf = new char[ArrayUtils.idealCharArraySize(len)];

    return buf;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:14,代码来源:TextUtils.java


示例14: 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


示例15: SparseLongArray

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
/**
 * Creates a new SparseLongArray 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 SparseLongArray(int initialCapacity) {
    if (initialCapacity == 0) {
        mKeys = ContainerHelpers.EMPTY_INTS;
        mValues = ContainerHelpers.EMPTY_LONGS;
    } else {
        initialCapacity = ArrayUtils.idealLongArraySize(initialCapacity);
        mKeys = new int[initialCapacity];
        mValues = new long[initialCapacity];
    }
    mSize = 0;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:19,代码来源:SparseLongArray.java


示例16: growKeyAndValueArrays

import com.android.internal.util.ArrayUtils; //导入依赖的package包/类
private void growKeyAndValueArrays(int minNeededSize) {
    int n = ArrayUtils.idealLongArraySize(minNeededSize);

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

    System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
    System.arraycopy(mValues, 0, nvalues, 0, mValues.length);

    mKeys = nkeys;
    mValues = nvalues;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:13,代码来源:SparseLongArray.java


示例17: 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


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Modifier类代码示例发布时间:2022-05-22
下一篇:
Java CharacterConverter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap