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


Java EmptyArray.OBJECT属性代码示例

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


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

示例1: ArrayMap

/**
 * Create a new ArrayMap with a given initial capacity.
 */
public ArrayMap(int capacity) {
    if (capacity == 0) {
        mHashes = EmptyArray.INT;
        mArray = EmptyArray.OBJECT;
    } else {
        allocArrays(capacity);
    }
    mSize = 0;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:12,代码来源:ArrayMap.java

示例2: clear

/**
 * Make the array map empty.  All storage is released.
 */
@Override
public void clear() {
    if (mSize > 0) {
        freeArrays(mHashes, mArray, mSize);
        mHashes = EmptyArray.INT;
        mArray = EmptyArray.OBJECT;
        mSize = 0;
    }
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:12,代码来源:ArrayMap.java

示例3: ArraySet

/**
 * Create a new ArraySet with a given initial capacity.
 */
public ArraySet(int capacity) {
    if (capacity == 0) {
        mHashes = EmptyArray.INT;
        mArray = EmptyArray.OBJECT;
    } else {
        allocArrays(capacity);
    }
    mSize = 0;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:12,代码来源:ArraySet.java

示例4: clear

/**
 * Make the array map empty.  All storage is released.
 */
@Override
public void clear() {
    if (mSize != 0) {
        freeArrays(mHashes, mArray, mSize);
        mHashes = EmptyArray.INT;
        mArray = EmptyArray.OBJECT;
        mSize = 0;
    }
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:12,代码来源:ArraySet.java

示例5: LongSparseArray

/**
 * 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:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:17,代码来源:LongSparseArray.java

示例6: SparseArray

/**
 * 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,代码行数:17,代码来源:SparseArray.java

示例7: trimToSize

/**
 * Sets the capacity of this {@code ArrayList} to be the same as the current
 * size.
 *
 * @see #size
 */
public void trimToSize() {
    int s = size;
    if (s == array.length) {
        return;
    }
    if (s == 0) {
        array = EmptyArray.OBJECT;
    } else {
        Object[] newArray = new Object[s];
        System.arraycopy(array, 0, newArray, 0, s);
        array = newArray;
    }
    modCount++;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:20,代码来源:ArrayList.java

示例8: readObject

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    int cap = stream.readInt();
    if (cap < size) {
        throw new InvalidObjectException(
                "Capacity: " + cap + " < size: " + size);
    }
    array = (cap == 0 ? EmptyArray.OBJECT : new Object[cap]);
    for (int i = 0; i < size; i++) {
        array[i] = stream.readObject();
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:12,代码来源:ArrayList.java

示例9: CopyOnWriteArrayList

/**
 * Creates a new empty instance.
 */
public CopyOnWriteArrayList() {
    elements = EmptyArray.OBJECT;
}
 
开发者ID:jtransc,项目名称:jtransc,代码行数:6,代码来源:CopyOnWriteArrayList.java

示例10: clear

@Override
public synchronized void clear() {
       elements = EmptyArray.OBJECT;
   }
 
开发者ID:jtransc,项目名称:jtransc,代码行数:4,代码来源:CopyOnWriteArrayList.java

示例11: removeAt

/**
 * 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.
 */
public V removeAt(int index) {
    final Object old = mArray[(index << 1) + 1];
    if (mSize <= 1) {
        // Now empty.
        if (DEBUG) Log.d(TAG, "remove: shrink from " + mHashes.length + " to 0");
        freeArrays(mHashes, mArray, mSize);
        mHashes = EmptyArray.INT;
        mArray = EmptyArray.OBJECT;
        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 << 1);
            }
            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) << 1, mArray, index << 1,
                        (mSize - index) << 1);
            }
        } 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) << 1, mArray, index << 1,
                        (mSize - index) << 1);
            }
            mArray[mSize << 1] = null;
            mArray[(mSize << 1) + 1] = null;
        }
    }
    return (V)old;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:55,代码来源:ArrayMap.java

示例12: removeAt

/**
 * 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.
 */
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 = EmptyArray.INT;
        mArray = EmptyArray.OBJECT;
        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;
}
 
开发者ID:Gracker,项目名称:Android-Framework-Tools-Utils,代码行数:52,代码来源:ArraySet.java

示例13: clear

@Override public synchronized void clear() {
    elements = EmptyArray.OBJECT;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:3,代码来源:CopyOnWriteArrayList.java

示例14: ArrayList

/**
 * Constructs a new {@code ArrayList} instance with zero initial capacity.
 */
public ArrayList() {
    array = EmptyArray.OBJECT;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:6,代码来源:ArrayList.java


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