本文整理汇总了Java中com.android.internal.util.ArrayUtils类的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils类的具体用法?Java ArrayUtils怎么用?Java ArrayUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayUtils类属于com.android.internal.util包,在下文中一共展示了ArrayUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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;
}
示例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;
}
示例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));
}
}
});
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}