Lines Matching refs:index
69 int index = ContainerHelpers.binarySearch(mHashes, N, hash);
72 if (index < 0) {
73 return index;
76 // If the key at the returned index matches, that's what we want.
77 if (key.equals(mArray[index<<1])) {
78 return index;
81 // Search for a matching key after the index.
83 for (end = index + 1; end < N && mHashes[end] == hash; end++) {
87 // Search for a matching key before the index.
88 for (int i = index - 1; i >= 0 && mHashes[i] == hash; i--) {
107 int index = ContainerHelpers.binarySearch(mHashes, N, 0);
110 if (index < 0) {
111 return index;
114 // If the key at the returned index matches, that's what we want.
115 if (null == mArray[index<<1]) {
116 return index;
119 // Search for a matching key after the index.
121 for (end = index + 1; end < N && mHashes[end] == 0; end++) {
125 // Search for a matching key before the index.
126 for (int i = index - 1; i >= 0 && mHashes[i] == 0; i--) {
277 * Returns the index of a key in the set.
280 * @return Returns the index of the key if it exists, else a negative integer.
323 final int index = indexOfKey(key);
324 return index >= 0 ? (V)mArray[(index<<1)+1] : null;
328 * Return the key at the given index in the array.
329 * @param index The desired index, must be between 0 and {@link #size()}-1.
330 * @return Returns the key stored at the given index.
332 public K keyAt(int index) {
333 return (K)mArray[index << 1];
337 * Return the value at the given index in the array.
338 * @param index The desired index, must be between 0 and {@link #size()}-1.
339 * @return Returns the value stored at the given index.
341 public V valueAt(int index) {
342 return (V)mArray[(index << 1) + 1];
346 * Set the value at a given index in the array.
347 * @param index The desired index, must be between 0 and {@link #size()}-1.
348 * @param value The new value to store at this index.
349 * @return Returns the previous value at the given index.
351 public V setValueAt(int index, V value) {
352 index = (index << 1) + 1;
353 V old = (V)mArray[index];
354 mArray[index] = value;
375 int index;
378 index = indexOfNull();
381 index = indexOf(key, hash);
383 if (index >= 0) {
384 index = (index<<1) + 1;
385 final V old = (V)mArray[index];
386 mArray[index] = value;
390 index = ~index;
410 if (index < mSize) {
411 if (DEBUG) Log.d(TAG, "put: move " + index + "-" + (mSize-index)
412 + " to " + (index+1));
413 System.arraycopy(mHashes, index, mHashes, index + 1, mSize - index);
414 System.arraycopy(mArray, index << 1, mArray, (index + 1) << 1, (mSize - index) << 1);
417 mHashes[index] = hash;
418 mArray[index<<1] = key;
419 mArray[(index<<1)+1] = value;
451 final int index = indexOfKey(key);
452 if (index >= 0) {
453 return removeAt(index);
460 * Remove the key/value mapping at the given index.
461 * @param index The desired index, must be between 0 and {@link #size()}-1.
462 * @return Returns the value that was stored at this index.
464 public V removeAt(int index) {
465 final Object old = mArray[(index << 1) + 1];
487 if (index > 0) {
488 if (DEBUG) Log.d(TAG, "remove: copy from 0-" + index + " to 0");
489 System.arraycopy(ohashes, 0, mHashes, 0, index);
490 System.arraycopy(oarray, 0, mArray, 0, index << 1);
492 if (index < mSize) {
493 if (DEBUG) Log.d(TAG, "remove: copy from " + (index+1) + "-" + mSize
494 + " to " + index);
495 System.arraycopy(ohashes, index + 1, mHashes, index, mSize - index);
496 System.arraycopy(oarray, (index + 1) << 1, mArray, index << 1,
497 (mSize - index) << 1);
501 if (index < mSize) {
502 if (DEBUG) Log.d(TAG, "remove: move " + (index+1) + "-" + mSize
503 + " to " + index);
504 System.arraycopy(mHashes, index + 1, mHashes, index, mSize - index);
505 System.arraycopy(mArray, (index + 1) << 1, mArray, index << 1,
506 (mSize - index) << 1);