Code example for HashMap

Methods: containsKey, get

0
     * Returns the average current in mA consumed by the subsystem  
     * @param type the subsystem type 
     * @return the average current in milliAmps. 
     */ 
    public double getAveragePower(String type) {
        if (sPowerMap.containsKey(type)) {
            Object data = sPowerMap.get(type);
            if (data instanceof Double[]) {
                return ((Double[])data)[0];
            } else { 
                return (Double) sPowerMap.get(type);
            } 
        } else { 
            return 0; 
        } 
    } 
     
    /** 
     * Returns the average current in mA consumed by the subsystem for the given level. 
     * @param type the subsystem type 
     * @param level the level of power at which the subsystem is running. For instance, the