1 /*
2  * Copyright (C) 2013 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 android.util;
18 
19 public class SparseIntArray {
20     private final SparseArray<Integer> mArray;
21 
SparseIntArray()22     public SparseIntArray() {
23         this(10);
24     }
25 
SparseIntArray(final int initialCapacity)26     public SparseIntArray(final int initialCapacity) {
27         mArray = new SparseArray<>(initialCapacity);
28     }
29 
size()30     public int size() {
31         return mArray.size();
32     }
33 
clear()34     public void clear() {
35         mArray.clear();
36     }
37 
put(final int key, final int value)38     public void put(final int key, final int value) {
39         mArray.put(key, value);
40     }
41 
get(final int key)42     public int get(final int key) {
43         return get(key, 0);
44     }
45 
get(final int key, final int valueIfKeyNotFound)46     public int get(final int key, final int valueIfKeyNotFound) {
47         return mArray.get(key, valueIfKeyNotFound);
48     }
49 
indexOfKey(final int key)50     public int indexOfKey(final int key) {
51         return mArray.indexOfKey(key);
52     }
53 
keyAt(final int index)54     public int keyAt(final int index) {
55         return mArray.keyAt(index);
56     }
57 }
58