Replaces an item in the hash. If the key doesn't exist, the
{@link #method-add} method will be used.
@param {String} key The key of the item.
@param {Object} value The new value for the item.
@return {Object} The new value of the item.
function(key, value) {
        var me = this,
            map = me.map,
            old;

        // Need to check arguments length here, since we could have called:
        // map.replace('foo', undefined);
        if (arguments.length === 1) {
            value = key;
            key = me.getKey(value);
        }

        if (!me.containsKey(key)) {
            me.add(key, value);
        }
        old = map[key];
        map[key] = value;
        if (me.hasListeners.replace) {
            me.fireEvent('replace', me, key, value, old);
        }
        return value;
    }