/** * Return a {@link java.util.Collection} for iterating over and interacting with all values * in the array map. * * <p><b>Note:</b> this is a fairly inefficient way to access the array contents, it * requires generating a number of temporary objects.</p> */ @Override public Collection<V> values() { return getCollection().getValues(); } }
/** * Returns the index for which {@link #keyAt} would return the * specified key, or a negative number if the specified * key is not mapped. */ public int indexOfKey(int key) { if (mGarbage) { gc(); } return ContainerHelpers.binarySearch(mKeys, mSize, key); }
public E put(String name, int uid, E value) { SparseArray<E> uids = mMap.get(name); if (uids == null) { uids = new SparseArray<E>(2); mMap.put(name, uids); } uids.put(uid, value); return value; }
public E remove(String name, int uid) { SparseArray<E> uids = mMap.get(name); if (uids != null) { final E old = uids.removeReturnOld(uid); if (uids.size() == 0) { mMap.remove(name); } return old; } return null; }
/** * Return a {@link java.util.Set} for iterating over and interacting with all keys * in the array map. * * <p><b>Note:</b> this is a fairly inefficient way to access the array contents, it * requires generating a number of temporary objects.</p> */ @Override public Set<K> keySet() { return getCollection().getKeySet(); }
public static VPackage get(String packageName) { synchronized (PackageCacheManager.class) { return PACKAGE_CACHE.get(packageName); } }
@Override protected void colClear() { clear(); } };
/** * Remove all keys in the array map that exist in the given collection. * @param collection The collection whose contents are to be used to remove keys. * @return Returns true if any keys were removed from the array map, else false. */ public boolean removeAll(Collection<?> collection) { return MapCollections.removeAllHelper(this, collection); }
/** * Remove all keys in the array map that do <b>not</b> exist in the given collection. * @param collection The collection whose contents are to be used to determine which * keys to keep. * @return Returns true if any keys were removed from the array map, else false. */ public boolean retainAll(Collection<?> collection) { return MapCollections.retainAllHelper(this, collection); }
/** * Given an index in the range <code>0...size()-1</code>, returns * the key from the <code>index</code>th key-value mapping that this * SparseArray stores. */ public int keyAt(int index) { if (mGarbage) { gc(); } return mKeys[index]; }
public Set<Map.Entry<K, V>> getEntrySet() { if (mEntrySet == null) { mEntrySet = new EntrySet(); } return mEntrySet; }
/** * Check whether a value exists in the array. This requires a linear search * through the entire array. * * @param value The value to search for. * @return Returns true if the value exists, else false. */ public boolean containsValue(Object value) { return indexOfValue(value) >= 0; }
public void add(int item) { ++mSize; ensureCapacity(); mData[mSize - 1] = item; }
public Set<K> getKeySet() { if (mKeySet == null) { mKeySet = new KeySet(); } return mKeySet; }
public Collection<V> getValues() { if (mValues == null) { mValues = new ValuesCollection(); } return mValues; }
/** * Create a new ArraySet with the mappings from the given ArraySet. */ public ArraySet(ArraySet<E> set) { this(); if (set != null) { addAll(set); } }
/** * Make the array map empty. All storage is released. */ @Override public void clear() { if (mSize != 0) { freeArrays(mHashes, mArray, mSize); mHashes = ContainerHelpers.EMPTY_INTS; mArray = ContainerHelpers.EMPTY_OBJECTS; mSize = 0; } }
@Override protected void colClear() { clear(); } };
public static PackageSetting getSetting(String packageName) { synchronized (PackageCacheManager.class) { VPackage p = PACKAGE_CACHE.get(packageName); if (p != null) { return (PackageSetting) p.mExtras; } return null; } }