Ext.ns('ux');
ux.HashMap = function()
{
    //internal data
    this.keys   = new Array();
    this.values = new Array();
    this.def    = null;

    //method definition
    this.put = function(key, item) {
        this.keys.push(key);
        this.values.push(item);
    }
    this.getDefault = function() {
        return this.def;
    }
    this.setDefault = function(newDefault) {
        this.def = newDefault;
    }

    this.get = function(key) {
        var keyPos = this.getPos(key);
        if (keyPos < 0)
            return this.def;
        return this.values[keyPos];
    }

    this.getKeys = function() {
        return this.keys;
    }

    this.remove = function(key) {
        var keyPos = this.getPos(key);
        if (keyPos < 0)
            return false;
        this.keys = this.removeInternal(this.keys, keyPos);
        this.values = this.removeInternal(this.values, keyPos);
    }
    
    this.getPos = function(key) {
        var keyPos = -1;
        Ext.each(this.keys, function(item, index) {
            if (item == key) {
                keyPos = index;
                return false;
            }
        });
        return keyPos;
    }
    
    this.getSize = function() {
        return this.keys.length;
    }
    
    this.removeInternal = function(arr, index) {
        var part1 = arr.slice( 0, index);
        var part2 = arr.slice( index+1 );
        return( part1.concat( part2 ) );
    }
}
