1package com.xtremelabs.robolectric.shadows;
2
3import android.util.SparseArray;
4import android.util.SparseIntArray;
5
6import com.xtremelabs.robolectric.internal.Implementation;
7import com.xtremelabs.robolectric.internal.Implements;
8import com.xtremelabs.robolectric.internal.RealObject;
9
10@Implements(SparseIntArray.class)
11public class ShadowSparseIntArray {
12
13	private SparseArray<Integer> sparseArray = new SparseArray<Integer>();
14
15	@RealObject
16	private SparseIntArray realObject;
17
18	@Implementation
19	public int get( int key ){
20		return get( key, 0 );
21	}
22
23	@Implementation
24	public int get(int key, int valueIfKeyNotFound){
25		return sparseArray.get( key, valueIfKeyNotFound );
26	}
27
28	@Implementation
29	public void put( int key, int value ){
30		sparseArray.put( key, value );
31	}
32
33	@Implementation
34	public int size() {
35		return sparseArray.size();
36	}
37
38	@Implementation
39	public int indexOfValue( int value ) {
40		return sparseArray.indexOfValue( value );
41	}
42
43	@Implementation
44	public int keyAt( int index ){
45		return sparseArray.keyAt( index );
46	}
47
48	@Implementation
49	public int valueAt( int index ){
50		return sparseArray.valueAt( index );
51	}
52
53	@Implementation
54	@Override
55	public SparseIntArray clone() {
56		SparseIntArray clone = new SparseIntArray();
57		for (int i = 0, length = size(); i < length; i++) {
58			clone.put( keyAt(i), valueAt(i) );
59		}
60		return clone;
61	}
62}
63