Code example for SparseArray

0
import java.util.Map; 
 
public class DynamicIdMap { 
 
    private final Map<Pair<ResourceType, String>, Integer> mDynamicIds = new HashMap<Pair<ResourceType, String>, Integer>();
    private final SparseArray<Pair<ResourceType, String>> mRevDynamicIds = new SparseArray<Pair<ResourceType, String>>();
    private int mDynamicSeed;
 
    public DynamicIdMap(int seed) {
        mDynamicSeed = seed;
    } 
 
    public void reset(int seed) {
        mDynamicIds.clear();
        mRevDynamicIds.clear();
        mDynamicSeed = seed;
    } 
 
    /** 
     * Returns a dynamic integer for the given resource type/name, creating it if it doesn't 
     * already exist.