ok

this[k] is not equal to this.push(k + ":" + v)
delete is an operator

(function($) {
// public:
       $.dict = [];

// private:
       var _len = 0;
       var _dict = [
               'set',
               'get',
               'del',
               'len',
               'toArray'
       ];

// public:
       $.dict.set = function(key, value) {
               if(!_dict.inarray(key)) {
                       this[key] = value;
                       _len++;
               }
       };

       $.dict.get = function(key) {
               if(!_dict.inarray(key)) {
                       return this[key];
               }
               return undefined;
       };

       $.dict.del = function(key) {
               if(!_dict.inarray(key)) {
                       delete this[key];
                       if (_len > 0)
                               _len--;
               }
       };

       $.dict.len = function() {
               return _len;
       };

       $.dict.toArray = function() {
               var a = [];
               for(k in this)
                       if(!_dict.inarray(k))
                               a.push(k + ":" + this[k]);
               return a;
       };

// private:
       _dict.inarray = function (v) {
               for (var i=0; i < this.length; i++)
                       if (this[i] === v)
                               return true;
               return false;
       };

})(jQuery);

Reply via email to