*/
WCF.Dictionary = function() { this.init(); };
WCF.Dictionary.prototype = {
+ /**
+ * list of variables
+ * @var object
+ */
+ _variables: { },
+
/**
* Initializes a new dictionary.
*/
- init: function() {
- this.variables = { };
- },
+ init: function() { },
/**
* Adds an entry.
* @param mixed value
*/
add: function(key, value) {
- this.variables[key] = value;
+ this._variables[key] = value;
},
/**
*/
get: function(key) {
if (this.isset(key)) {
- return this.variables[key];
+ return this._variables[key];
}
return null;
* @param string key
*/
isset: function(key) {
- return this.variables.hasOwnProperty(key);
+ return this._variables.hasOwnProperty(key);
},
/**
* @param string key
*/
remove: function(key) {
- delete this.variables[key];
+ delete this._variables[key];
},
/**
return;
}
- for (var $key in this.variables) {
- var $value = this.variables[$key];
+ for (var $key in this._variables) {
+ var $value = this._variables[$key];
var $pair = {
key: $key,
value: $value
callback($pair);
}
+ },
+
+ /**
+ * Returns the amount of items.
+ *
+ * @return integer
+ */
+ count: function() {
+ return $.getLength(this._variables);
+ },
+
+ /**
+ * Returns true, if dictionary is empty.
+ *
+ * @return integer
+ */
+ isEmpty: function() {
+ return !this.count();
}
};