/**
 * CKW.Registry.js
 *
 * A class to emulate an associative array
 *
 * Author:       Chris Knowles<chris.knowles@ckweb.com.au>
 * Date:         24/03/2006
 * Last Updated: 24/03/2006
 */

CKW.AssocArray = function()
{
    this.vals = new Object();
    this.length = 0;
}

CKW.AssocArray.prototype =
{
    set: function(name, value)
    {
        this.vals[name] = value;
        this.length++;
    },

    get: function(name)
    {
        if (this.vals[name]) {
            return this.vals[name];
        }
        return false;
    },

    update: function(data)
    {
        for (name in data) {
            if (this.vals[name]) {
                this.vals[name] = data[name];
            }
        }
    },

    add: function(data)
    {
        for (name in data) {
            this.vals[name] = data[name];
            this.length++;
        }
    },

    empty: function()
    {
        this.vals = new Object();
        this.length = 0;
    },

    unset: function(name)
    {
        this.vals[name] = null;
        this.length--;
    },

    remove: function(name)
    {
        delete this.vals[name];
        this.length--;
    }

}
