Jinsuk Kim | 30c74d9 | 2014-08-05 17:30:09 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.hdmi; |
| 18 | |
| 19 | import android.util.SparseArray; |
| 20 | |
| 21 | /** |
| 22 | * Unmodifiable version of {@link SparseArray}. |
| 23 | */ |
| 24 | final class UnmodifiableSparseArray<E> { |
| 25 | private static final String TAG = "ImmutableSparseArray"; |
| 26 | |
| 27 | private final SparseArray<E> mArray; |
| 28 | |
| 29 | public UnmodifiableSparseArray(SparseArray<E> array) { |
| 30 | mArray = array; |
| 31 | } |
| 32 | |
| 33 | public int size() { |
| 34 | return mArray.size(); |
| 35 | } |
| 36 | |
| 37 | public E get(int key) { |
| 38 | return mArray.get(key); |
| 39 | } |
| 40 | |
| 41 | public E get(int key, E valueIfKeyNotFound) { |
| 42 | return mArray.get(key, valueIfKeyNotFound); |
| 43 | } |
| 44 | |
| 45 | public int keyAt(int index) { |
| 46 | return mArray.keyAt(index); |
| 47 | } |
| 48 | |
| 49 | public E valueAt(int index) { |
| 50 | return mArray.valueAt(index); |
| 51 | } |
| 52 | |
| 53 | public int indexOfValue(E value) { |
| 54 | return mArray.indexOfValue(value); |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public String toString() { |
| 59 | return mArray.toString(); |
| 60 | } |
| 61 | } |