Lines Matching refs:key

69      * Gets the Object mapped from the specified key, or <code>null</code>
72 public E get(int key) {
73 return get(key, null);
77 * Gets the Object mapped from the specified key, or the specified Object
81 public E get(int key, E valueIfKeyNotFound) {
82 int i = binarySearch(mKeys, 0, mSize, key);
92 * Removes the mapping from the specified key, if there was any.
94 public void delete(int key) {
95 int i = binarySearch(mKeys, 0, mSize, key);
108 public void remove(int key) {
109 delete(key);
151 * Adds a mapping from the specified key to the specified value,
152 * replacing the previous mapping from the specified key if there
155 public void put(int key, E value) {
156 int i = binarySearch(mKeys, 0, mSize, key);
164 mKeys[i] = key;
173 i = ~binarySearch(mKeys, 0, mSize, key);
196 mKeys[i] = key;
203 * Returns the number of key-value mappings that this SparseArray
216 * the key from the <code>index</code>th key-value mapping that this
229 * the value from the <code>index</code>th key-value mapping that this
243 * value for the <code>index</code>th key-value mapping that this
256 * specified key, or a negative number if the specified
257 * key is not mapped.
259 public int indexOfKey(int key) {
264 return binarySearch(mKeys, 0, mSize, key);
269 * specified key, or a negative number if no keys map to the
271 * Beware that this is a linear search, unlike lookups by key,
288 * Removes all key-value mappings from this SparseArray.
303 * Puts a key/value pair into the array, optimizing for the case where
304 * the key is greater than all existing keys in the array.
306 public void append(int key, E value) {
307 if (mSize != 0 && key <= mKeys[mSize - 1]) {
308 put(key, value);
331 mKeys[pos] = key;
336 private static int binarySearch(int[] a, int start, int len, int key) {
342 if (a[guess] < key)
350 else if (a[high] == key)