List of usage examples for android.support.v4.util SupportContainerInternals EMPTY_INTS
null EMPTY_INTS
To view the source code for android.support.v4.util SupportContainerInternals EMPTY_INTS.
Click Source Link
From source file:io.sweers.arraysetbackport.ArraySet.java
/** * Create a new empty ArraySet. The default capacity of an array map is 0, and * will grow once items are added to it. *//* w w w . ja v a 2 s. c o m*/ public ArraySet() { mHashes = SupportContainerInternals.EMPTY_INTS; mArray = SupportContainerInternals.EMPTY_OBJECTS; mSize = 0; }
From source file:io.sweers.arraysetbackport.ArraySet.java
/** * Create a new ArraySet with a given initial capacity. *///from w w w. jav a 2 s . co m public ArraySet(int capacity) { if (capacity == 0) { mHashes = SupportContainerInternals.EMPTY_INTS; mArray = SupportContainerInternals.EMPTY_OBJECTS; } else { allocArrays(capacity); } mSize = 0; }
From source file:io.sweers.arraysetbackport.ArraySet.java
/** * Make the array map empty. All storage is released. *//*from w ww.j av a 2 s . co m*/ @Override public void clear() { if (mSize != 0) { freeArrays(mHashes, mArray, mSize); mHashes = SupportContainerInternals.EMPTY_INTS; mArray = SupportContainerInternals.EMPTY_OBJECTS; mSize = 0; } }
From source file:io.sweers.arraysetbackport.ArraySet.java
/** * Remove the key/value mapping at the given index. * @param index The desired index, must be between 0 and {@link #size()}-1. * @return Returns the value that was stored at this index. *//*from w ww. j a va 2s . com*/ public E removeAt(int index) { final Object old = mArray[index]; if (mSize <= 1) { // Now empty. if (DEBUG) Log.d(TAG, "remove: shrink from " + mHashes.length + " to 0"); freeArrays(mHashes, mArray, mSize); mHashes = SupportContainerInternals.EMPTY_INTS; mArray = SupportContainerInternals.EMPTY_OBJECTS; mSize = 0; } else { if (mHashes.length > (BASE_SIZE * 2) && mSize < mHashes.length / 3) { // Shrunk enough to reduce size of arrays. We don't allow it to // shrink smaller than (BASE_SIZE*2) to avoid flapping between // that and BASE_SIZE. final int n = mSize > (BASE_SIZE * 2) ? (mSize + (mSize >> 1)) : (BASE_SIZE * 2); if (DEBUG) Log.d(TAG, "remove: shrink from " + mHashes.length + " to " + n); final int[] ohashes = mHashes; final Object[] oarray = mArray; allocArrays(n); mSize--; if (index > 0) { if (DEBUG) Log.d(TAG, "remove: copy from 0-" + index + " to 0"); System.arraycopy(ohashes, 0, mHashes, 0, index); System.arraycopy(oarray, 0, mArray, 0, index); } if (index < mSize) { if (DEBUG) Log.d(TAG, "remove: copy from " + (index + 1) + "-" + mSize + " to " + index); System.arraycopy(ohashes, index + 1, mHashes, index, mSize - index); System.arraycopy(oarray, index + 1, mArray, index, mSize - index); } } else { mSize--; if (index < mSize) { if (DEBUG) Log.d(TAG, "remove: move " + (index + 1) + "-" + mSize + " to " + index); System.arraycopy(mHashes, index + 1, mHashes, index, mSize - index); System.arraycopy(mArray, index + 1, mArray, index, mSize - index); } mArray[mSize] = null; } } return (E) old; }