Lines Matching defs:key

26  * ArrayMap is a generic key->value mapping data structure that is
29 * codes for each item, and an Object array of the key/value pairs. This allows it to
88 int indexOf(Object key, int hash) {
98 // If the hash code wasn't found, then we have no entry for this key.
103 // If the key at the returned index matches, that's what we want.
104 if (key.equals(mArray[index<<1])) {
108 // Search for a matching key after the index.
111 if (key.equals(mArray[end << 1])) return end;
114 // Search for a matching key before the index.
116 if (key.equals(mArray[i << 1])) return i;
120 // new entry for this key should go. We use the end of the
136 // If the hash code wasn't found, then we have no entry for this key.
141 // If the key at the returned index matches, that's what we want.
146 // Search for a matching key after the index.
152 // Search for a matching key before the index.
158 // new entry for this key should go. We use the end of the
322 * Check whether a key exists in the array.
324 * @param key The key to search for.
325 * @return Returns true if the key exists, else false.
328 public boolean containsKey(Object key) {
329 return indexOfKey(key) >= 0;
333 * Returns the index of a key in the set.
335 * @param key The key to search for.
336 * @return Returns the index of the key if it exists, else a negative integer.
338 public int indexOfKey(Object key) {
339 return key == null ? indexOfNull() : indexOf(key, key.hashCode());
375 * @param key The key of the value to retrieve.
376 * @return Returns the value associated with the given key,
377 * or null if there is no such key.
380 public V get(Object key) {
381 final int index = indexOfKey(key);
386 * Return the key at the given index in the array.
388 * @return Returns the key stored at the given index.
426 * @param key The key under which to store the value. If
427 * this key already exists in the array, its value will be replaced.
428 * @param value The value to store for the given key.
429 * @return Returns the old value that was stored for the given key, or null if there
430 * was no such key.
433 public V put(K key, V value) {
436 if (key == null) {
440 hash = key.hashCode();
441 index = indexOf(key, hash);
478 mArray[index<<1] = key;
489 public void append(K key, V value) {
491 final int hash = key == null ? 0 : key.hashCode();
500 + " at index " + index + " key " + key, e);
501 put(key, value);
507 mArray[index] = key;
513 * an array map where the same key appears multiple times. This function verifies that
540 throw new IllegalArgumentException("Duplicate key in ArrayMap: " + cur);
543 throw new IllegalArgumentException("Duplicate key in ArrayMap: " + cur);
550 * Perform a {@link #put(Object, Object)} of all key/value pairs in <var>array</var>
570 * Remove an existing key from the array map.
571 * @param key The key of the mapping to remove.
572 * @return Returns the value that was stored under the key, or null if there
573 * was no such key.
576 public V remove(Object key) {
577 final int index = indexOfKey(key);
586 * Remove the key/value mapping at the given index.
653 * if the maps have different sizes. Otherwise, for each key in this map,
654 * values of both maps are compared. If the values for any key are not
670 K key = keyAt(i);
672 Object theirs = map.get(key);
674 if (theirs != null || !map.containsKey(key)) {
710 * this map contains itself as a key or a value, the string "(this Map)"
725 Object key = keyAt(i);
726 if (key != this) {
727 buffer.append(key);
762 protected int colIndexOfKey(Object key) {
763 return indexOfKey(key);
777 protected void colPut(K key, V value) {
778 put(key, value);
803 * @return Returns true if this array map contains a key for every entry
811 * Perform a {@link #put(Object, Object)} of all key/value pairs in <var>map</var>