Lines Matching refs:key

68      * Gets the long mapped from the specified key, or <code>0</code>
71 public long get(int key) {
72 return get(key, 0);
76 * Gets the long mapped from the specified key, or the specified value
79 public long get(int key, long valueIfKeyNotFound) {
80 int i = binarySearch(mKeys, 0, mSize, key);
90 * Removes the mapping from the specified key, if there was any.
92 public void delete(int key) {
93 int i = binarySearch(mKeys, 0, mSize, key);
110 * Adds a mapping from the specified key to the specified value,
111 * replacing the previous mapping from the specified key if there
114 public void put(int key, long value) {
115 int i = binarySearch(mKeys, 0, mSize, key);
131 mKeys[i] = key;
138 * Returns the number of key-value mappings that this SparseIntArray
147 * the key from the <code>index</code>th key-value mapping that this
156 * the value from the <code>index</code>th key-value mapping that this
165 * specified key, or a negative number if the specified
166 * key is not mapped.
168 public int indexOfKey(int key) {
169 return binarySearch(mKeys, 0, mSize, key);
174 * specified key, or a negative number if no keys map to the
176 * Beware that this is a linear search, unlike lookups by key,
189 * Removes all key-value mappings from this SparseIntArray.
196 * Puts a key/value pair into the array, optimizing for the case where
197 * the key is greater than all existing keys in the array.
199 public void append(int key, long value) {
200 if (mSize != 0 && key <= mKeys[mSize - 1]) {
201 put(key, value);
210 mKeys[pos] = key;
228 private static int binarySearch(int[] a, int start, int len, long key) {
234 if (a[guess] < key)
242 else if (a[high] == key)