47,673 → 47,676 |
* |
* @function |
*/ |
Map: jsx.object.extend(( |
/** |
* @return {jsx.map.Map} |
*/ |
function () { |
Map: jsx.object.extend( |
( |
/** |
* A value in the map, to distinguish it from built-in types |
* |
* @param value Value to be stored |
* @param key Optional key for the value. Used by {@link _Bucket}. |
* @private |
* @return {jsx.map.Map} |
*/ |
function _ValueContainer(value, key) |
{ |
this.putValue(value, key); |
} |
|
/** |
* @param value |
* @return {boolean} |
* <code>true</code> if <var>v</var> was created using |
* {@link _ValueContainer}, otherwise <code>false</code> |
*/ |
_ValueContainer.isInstance = function (value) { |
return !!value && value.constructor === this; |
}; |
|
_ValueContainer.prototype.putValue = function (value, key) { |
this._value = value; |
this._key = key; |
}; |
|
_ValueContainer.prototype.getValue = function () { |
return this._value; |
}; |
|
_ValueContainer.prototype.getKey = function () { |
return this._key; |
}; |
|
var _getDataObject = jsx.object.getDataObject; |
|
/** |
* In order not to overwrite or shadow built-in properties, if a key is |
* the name of such a property, an alias property name is used instead. |
* A maximum length of the alias property name is necessary to avoid |
* infinite iteration for finding an alias if the previously computed |
* alias is already used as name of a built-in property. |
*/ |
var _maxAliasLength = 255; |
|
var _isObjectRef = jsx.object.isObject; |
|
/** |
* Returns a safe key, that is, a property name that is not yet used |
* by the ECMAScript implementation. |
* |
* @param unsafeKey |
* Potentially unsafe key, that is, a property name that may be |
* already used by the ECMAScript implementation. |
* @return {string} |
* @throws jsx.map#KeyError if the user-defined maximum key length |
* does not suffice to satisfy a safe key. |
* @private |
*/ |
function _getSafeKey (obj, unsafeKey) |
{ |
var |
safeKey = unsafeKey, |
constructor = obj.constructor, |
proto = (constructor ? constructor.prototype : null); |
|
if (_isObjectRef(unsafeKey)) |
function () { |
/** |
* A value in the map, to distinguish it from built-in types |
* |
* @param value Value to be stored |
* @param key Optional key for the value. Used by {@link _Bucket}. |
* @private |
*/ |
function _ValueContainer(value, key) |
{ |
var _class = jsx.object.getClass(unsafeKey); |
var constructorName = jsx.object.getFunctionName(unsafeKey.constructor); |
safeKey = (_class ? "[" + _class + "]" : "") |
+ (constructorName ? constructorName + "()" : "") |
+ (typeof unsafeKey.nodeName != "undefined" |
? unsafeKey.nodeName |
: "") |
+ (typeof unsafeKey.id != "undefined" |
? "#" + unsafeKey.id |
: "") |
+ (typeof unsafeKey.className != "undefined" |
&& /\S/.test(unsafeKey.className) |
? "." + unsafeKey.className.replace(/\s+/, ".") |
: ""); |
this.putValue(value, key); |
} |
|
/* |
* Try until an unused (not inherited and not own non-_ValueContainer) property |
* was found or the maximum alias key length has been reached |
/** |
* @param value |
* @return {boolean} |
* <code>true</code> if <var>v</var> was created using |
* {@link _ValueContainer}, otherwise <code>false</code> |
*/ |
while (proto && (_hasOwnProperty(proto, safeKey) |
|| (_hasOwnProperty(obj, safeKey) |
&& !_ValueContainer.isInstance(obj[safeKey])))) |
{ |
if (safeKey.length > _maxAliasLength) |
{ |
jsx.throwThis("jsx.map.KeyError", unsafeKey); |
} |
_ValueContainer.isInstance = function (value) { |
return !!value && value.constructor === this; |
}; |
|
safeKey += "_"; |
} |
_ValueContainer.prototype.putValue = function (value, key) { |
this._value = value; |
this._key = key; |
}; |
|
return safeKey; |
} |
_ValueContainer.prototype.getValue = function () { |
return this._value; |
}; |
|
function _Bucket() |
{ |
this._items = _getDataObject(); |
} |
_ValueContainer.prototype.getKey = function () { |
return this._key; |
}; |
|
/** |
* @param value |
* @return {boolean} |
* <code>true</code> if <var>v</var> was created using |
* {@link _Bucket}, otherwise <code>false</code> |
*/ |
_Bucket.isInstance = function (value) { |
return !!value && value.constructor === this; |
}; |
var _getDataObject = jsx.object.getDataObject; |
|
_Bucket._nextId = 1; |
/** |
* In order not to overwrite or shadow built-in properties, if a key is |
* the name of such a property, an alias property name is used instead. |
* A maximum length of the alias property name is necessary to avoid |
* infinite iteration for finding an alias if the previously computed |
* alias is already used as name of a built-in property. |
*/ |
var _maxAliasLength = 255; |
|
_Bucket.extend(null, { |
var _isObjectRef = jsx.object.isObject; |
|
/** |
* Returns the next string key for this bucket |
* Returns a safe key, that is, a property name that is not yet used |
* by the ECMAScript implementation. |
* |
* @memberOf _Bucket.prototype |
* @param unsafeKey |
* Potentially unsafe key, that is, a property name that may be |
* already used by the ECMAScript implementation. |
* @return {string} |
* @throws jsx.map#KeyError if the user-defined maximum key length |
* does not suffice to satisfy a safe key. |
* @private |
* @return {string} |
*/ |
_getNextId: function () { |
return "key" + (_Bucket._nextId++) + "_"; |
}, |
function _getSafeKey (obj, unsafeKey) |
{ |
var |
safeKey = unsafeKey, |
constructor = obj.constructor, |
proto = (constructor ? constructor.prototype : null); |
|
/** |
* Puts a value in the bucket |
* |
* @param oKey |
* @return {_ValueContainer} |
* The previous container for this key, |
* <code>null</code> if none. |
*/ |
put: function (oKey, value) { |
var prevValue = null; |
var items = this._items; |
var sKey = this.find(oKey); |
if (!sKey) |
if (_isObjectRef(unsafeKey)) |
{ |
sKey = _getSafeKey(items, this._getNextId()); |
var _class = jsx.object.getClass(unsafeKey); |
var constructorName = jsx.object.getFunctionName(unsafeKey.constructor); |
safeKey = (_class ? "[" + _class + "]" : "") |
+ (constructorName ? constructorName + "()" : "") |
+ (typeof unsafeKey.nodeName != "undefined" |
? unsafeKey.nodeName |
: "") |
+ (typeof unsafeKey.id != "undefined" |
? "#" + unsafeKey.id |
: "") |
+ (typeof unsafeKey.className != "undefined" |
&& /\S/.test(unsafeKey.className) |
? "." + unsafeKey.className.replace(/\s+/, ".") |
: ""); |
} |
else |
|
/* |
* Try until an unused (not inherited and not own non-_ValueContainer) property |
* was found or the maximum alias key length has been reached |
*/ |
while (proto && (_hasOwnProperty(proto, safeKey) |
|| (_hasOwnProperty(obj, safeKey) |
&& !_ValueContainer.isInstance(obj[safeKey])))) |
{ |
prevValue = items[sKey]; |
if (safeKey.length > _maxAliasLength) |
{ |
jsx.throwThis("jsx.map.KeyError", unsafeKey); |
} |
|
safeKey += "_"; |
} |
|
items[sKey] = new _ValueContainer(value, oKey); |
return safeKey; |
} |
|
return prevValue; |
}, |
function _Bucket() |
{ |
this._items = _getDataObject(); |
} |
|
/** |
* Gets a value from the bucket |
* |
* @param oKey |
* @return {string} |
* The value for the object key |
* @param value |
* @return {boolean} |
* <code>true</code> if <var>v</var> was created using |
* {@link _Bucket}, otherwise <code>false</code> |
*/ |
get: function (oKey) { |
var sKey = this.find(oKey); |
if (!sKey) |
{ |
return void 0; |
} |
_Bucket.isInstance = function (value) { |
return !!value && value.constructor === this; |
}; |
|
return this._items[sKey]; |
}, |
_Bucket._nextId = 1; |
|
/** |
* Returns the string key of an object |
* |
* @param oKey |
* @return {string|boolean} |
* The string key of <var>oKey</var> if it is in the bucket, |
* <code>false</code> otherwise. |
*/ |
find: function (oKey) { |
var items = this._items; |
for (var sKey in items) |
{ |
var value = items[sKey]; |
if (_ValueContainer.isInstance(value) && value.getKey() == oKey) |
_Bucket.extend(null, { |
/** |
* Returns the next string key for this bucket |
* |
* @memberOf _Bucket.prototype |
* @private |
* @return {string} |
*/ |
_getNextId: function () { |
return "key" + (_Bucket._nextId++) + "_"; |
}, |
|
/** |
* Puts a value in the bucket |
* |
* @param oKey |
* @return {_ValueContainer} |
* The previous container for this key, |
* <code>null</code> if none. |
*/ |
put: function (oKey, value) { |
var prevValue = null; |
var items = this._items; |
var sKey = this.find(oKey); |
if (!sKey) |
{ |
return sKey; |
sKey = _getSafeKey(items, this._getNextId()); |
} |
} |
else |
{ |
prevValue = items[sKey]; |
} |
|
return false; |
}, |
items[sKey] = new _ValueContainer(value, oKey); |
|
/** |
* Removes an object key from the bucket |
* |
* @param oKey |
* @return {string|boolean} |
* The removed value for the object key, |
* or <code>false</code> if it was not in the bucket. |
*/ |
remove: function (oKey) { |
var sKey = this.find(oKey); |
if (sKey) |
{ |
var value = this._items[sKey]; |
delete this._items[sKey]; |
} |
return prevValue; |
}, |
|
return value; |
}, |
/** |
* Gets a value from the bucket |
* |
* @param oKey |
* @return {string} |
* The value for the object key |
*/ |
get: function (oKey) { |
var sKey = this.find(oKey); |
if (!sKey) |
{ |
return void 0; |
} |
|
keys: function () { |
var a = []; |
return this._items[sKey]; |
}, |
|
var items = this._items; |
for (var key in items) |
{ |
var o = items[key]; |
if (_ValueContainer.isInstance(o)) |
/** |
* Returns the string key of an object |
* |
* @param oKey |
* @return {string|boolean} |
* The string key of <var>oKey</var> if it is in the bucket, |
* <code>false</code> otherwise. |
*/ |
find: function (oKey) { |
var items = this._items; |
for (var sKey in items) |
{ |
a.push(o.getKey()); |
var value = items[sKey]; |
if (_ValueContainer.isInstance(value) && value.getKey() == oKey) |
{ |
return sKey; |
} |
} |
} |
|
return a; |
}, |
return false; |
}, |
|
mappings: function () { |
var a = []; |
/** |
* Removes an object key from the bucket |
* |
* @param oKey |
* @return {string|boolean} |
* The removed value for the object key, |
* or <code>false</code> if it was not in the bucket. |
*/ |
remove: function (oKey) { |
var sKey = this.find(oKey); |
if (sKey) |
{ |
var value = this._items[sKey]; |
delete this._items[sKey]; |
} |
|
var items = this._items; |
for (var p in items) |
{ |
var o = items[p]; |
return value; |
}, |
|
if (_ValueContainer.isInstance(o)) |
keys: function () { |
var a = []; |
|
var items = this._items; |
for (var key in items) |
{ |
a.push([o.getKey(), o.getValue()]); |
var o = items[key]; |
if (_ValueContainer.isInstance(o)) |
{ |
a.push(o.getKey()); |
} |
} |
} |
|
return a; |
} |
}); |
return a; |
}, |
|
/* Imports */ |
var _hasOwnProperty = jsx.object._hasOwnProperty; |
mappings: function () { |
var a = []; |
|
/** |
* @param {jsx.map.Map} map |
* The map whose mappings are to be placed in this map |
* @param {Boolean} strictKeys (optional) |
* If <code>true</code>, keys are stored as they are. |
* Otherwise only object keys are stored as they are, |
* and other keys are converted to string. The default |
* is <code>false</code>. |
* @constructor |
*/ |
function _Map (map, strictKeys) |
{ |
// var Map = arguments.callee; |
var items = this._items; |
for (var p in items) |
{ |
var o = items[p]; |
|
/* Allows to use this as a factory */ |
if (!this || this.constructor != _Map) |
{ |
return new _Map(map); |
} |
if (_ValueContainer.isInstance(o)) |
{ |
a.push([o.getKey(), o.getValue()]); |
} |
} |
|
var _items = _getDataObject(); |
var _size = 0; |
return a; |
} |
}); |
|
/** |
* Gets the maximum alias property name length |
* for further storage and retrieval operations. |
* The default is 255. |
* |
* @return {boolean} |
* <code>true</code> if successful, |
* <code>false</code> otherwise. |
* @public |
*/ |
this.getMaxAliasLength = function () { |
return _maxAliasLength; |
}; |
/* Imports */ |
var _hasOwnProperty = jsx.object._hasOwnProperty; |
|
/** |
* Sets the maximum alias property name length |
* for further storage and retrieval operations. |
* |
* @param {number} len |
* Integer greater than 0 to define the maximum |
* alias property name length. The default maximum is 255. |
* @return {boolean} |
* <code>true</code> if successful, |
* <code>false</code> otherwise. |
* @throws jsx.map#InvalidLengthError |
* @public |
* @param {jsx.map.Map} map |
* The map whose mappings are to be placed in this map |
* @param {Boolean} strictKeys (optional) |
* If <code>true</code>, keys are stored as they are. |
* Otherwise only object keys are stored as they are, |
* and other keys are converted to string. The default |
* is <code>false</code>. |
* @constructor |
*/ |
this.setMaxAliasLength = function (len) { |
if (typeof len != "number") |
{ |
len = parseInt(len, 10); |
} |
function _Map (map, strictKeys) |
{ |
// var Map = arguments.callee; |
|
if (isNaN(len) || len < 1) |
/* Allows to use this as a factory */ |
if (!this || this.constructor != _Map) |
{ |
jsx.throwThis("jsx.map.InvalidLengthError"); |
return new _Map(map); |
} |
|
_maxAliasLength = len; |
var _items = _getDataObject(); |
var _size = 0; |
|
return _maxAliasLength === len; |
}; |
/** |
* Gets the maximum alias property name length |
* for further storage and retrieval operations. |
* The default is 255. |
* |
* @return {boolean} |
* <code>true</code> if successful, |
* <code>false</code> otherwise. |
* @public |
*/ |
this.getMaxAliasLength = function () { |
return _maxAliasLength; |
}; |
|
/** |
* Returns the number of key-value mappings in this map |
* |
* @return {number} |
* The number of key-value mappings in this map |
* @public |
*/ |
this.size = function () { |
return _size; |
}; |
/** |
* Sets the maximum alias property name length |
* for further storage and retrieval operations. |
* |
* @param {number} len |
* Integer greater than 0 to define the maximum |
* alias property name length. The default maximum is 255. |
* @return {boolean} |
* <code>true</code> if successful, |
* <code>false</code> otherwise. |
* @throws jsx.map#InvalidLengthError |
* @public |
*/ |
this.setMaxAliasLength = function (len) { |
if (typeof len != "number") |
{ |
len = parseInt(len, 10); |
} |
|
/** |
* Returns <code>true</code> if this map contains no key-value mappings |
* |
* @return {boolean} |
* <code>true</code> if this map contains no key-value mappings |
* @public |
*/ |
this.isEmpty = function () { |
return _size === 0; |
}; |
if (isNaN(len) || len < 1) |
{ |
jsx.throwThis("jsx.map.InvalidLengthError"); |
} |
|
/** |
* Returns the value to which the specified key is mapped in this map |
* |
* @param key |
* @param defaultValue |
* @throws jsx.map#KeyError |
* If there is no such key and no default value has been passed. |
* @public |
*/ |
this.get = function (key, defaultValue) { |
var v = _items[_getSafeKey(_items, key)]; |
_maxAliasLength = len; |
|
if (_isObjectRef(key)) |
{ |
if (_Bucket.isInstance(v)) |
return _maxAliasLength === len; |
}; |
|
/** |
* Returns the number of key-value mappings in this map |
* |
* @return {number} |
* The number of key-value mappings in this map |
* @public |
*/ |
this.size = function () { |
return _size; |
}; |
|
/** |
* Returns <code>true</code> if this map contains no key-value mappings |
* |
* @return {boolean} |
* <code>true</code> if this map contains no key-value mappings |
* @public |
*/ |
this.isEmpty = function () { |
return _size === 0; |
}; |
|
/** |
* Returns the value to which the specified key is mapped in this map |
* |
* @param key |
* @param defaultValue |
* @throws jsx.map#KeyError |
* If there is no such key and no default value has been passed. |
* @public |
*/ |
this.get = function (key, defaultValue) { |
var v = _items[_getSafeKey(_items, key)]; |
|
if (_isObjectRef(key)) |
{ |
v = v.get(key); |
if (_Bucket.isInstance(v)) |
{ |
v = v.get(key); |
} |
} |
} |
|
if (!v) |
{ |
if (arguments.length > 1) |
if (!v) |
{ |
return defaultValue; |
if (arguments.length > 1) |
{ |
return defaultValue; |
} |
|
jsx.throwThis("jsx.map.KeyError", key); |
} |
|
jsx.throwThis("jsx.map.KeyError", key); |
} |
return v.getValue(); |
}; |
|
return v.getValue(); |
}; |
/** |
* Returns <code>true</code> if this map contains a mapping for the specified key |
* |
* @param key |
* @return {boolean} |
* @public |
*/ |
this.containsKey = function (key) { |
var value = _items[_getSafeKey(_items, key)]; |
return _ValueContainer.isInstance(value) |
|| (_Bucket.isInstance(value) && !!value.find(key)); |
}; |
|
/** |
* Returns <code>true</code> if this map contains a mapping for the specified key |
* |
* @param key |
* @return {boolean} |
* @public |
*/ |
this.containsKey = function (key) { |
var value = _items[_getSafeKey(_items, key)]; |
return _ValueContainer.isInstance(value) |
|| (_Bucket.isInstance(value) && !!value.find(key)); |
}; |
/** |
* Associates the specified value with the specified key in this map |
* |
* @param key |
* @param value |
* @return {boolean} |
* Previous value associated with specified key, |
* or <code>undefined</code> if there was no mapping for <var>key</var>. |
* An <code>undefined</code> return can also indicate that the Map |
* previously associated <code>undefined</code> with the specified key. |
* @throws jsx.map#KeyError |
* @public |
*/ |
this.put = function (key, value) { |
var k = _getSafeKey(_items, key); |
var v; |
var prevValue = _items[k]; |
|
/** |
* Associates the specified value with the specified key in this map |
* |
* @param key |
* @param value |
* @return {boolean} |
* Previous value associated with specified key, |
* or <code>undefined</code> if there was no mapping for <var>key</var>. |
* An <code>undefined</code> return can also indicate that the Map |
* previously associated <code>undefined</code> with the specified key. |
* @throws jsx.map#KeyError |
* @public |
*/ |
this.put = function (key, value) { |
var k = _getSafeKey(_items, key); |
var v; |
var prevValue = _items[k]; |
|
if (_isObjectRef(key) || (typeof key != "string" && this.strictKeys)) |
{ |
var bucket = prevValue; |
if (_Bucket.isInstance(bucket)) |
if (_isObjectRef(key) || (typeof key != "string" && this.strictKeys)) |
{ |
if (!bucket.find(key)) |
var bucket = prevValue; |
if (_Bucket.isInstance(bucket)) |
{ |
if (!bucket.find(key)) |
{ |
++_size; |
} |
} |
else |
{ |
bucket = new _Bucket(); |
++_size; |
} |
|
prevValue = bucket.put(key, value); |
v = bucket; |
} |
else |
{ |
bucket = new _Bucket(); |
++_size; |
v = new _ValueContainer(value); |
if (!prevValue) |
{ |
++_size; |
} |
} |
|
prevValue = bucket.put(key, value); |
v = bucket; |
} |
else |
{ |
v = new _ValueContainer(value); |
if (!prevValue) |
{ |
++_size; |
} |
} |
_items[k] = v; |
|
_items[k] = v; |
return prevValue && prevValue.getValue(); |
}; |
|
return prevValue && prevValue.getValue(); |
}; |
/** |
* Removes the mapping for the specified key from this map if present |
* |
* @param key |
* Key whose mapping is to be removed from the map |
* @return {any} |
* The previous value associated with <var>key</var>,_value |
* or <code>undefined</code> if there was no mapping for <var>key</var>. |
* (An <code>undefined</code> return can also indicate that the map |
* previously associated <code>undefined</code> with <var>key</var>.) |
* @throws jsx.map#KeyError |
* @public |
*/ |
this.remove = function (key) { |
var k = _getSafeKey(_items, key); |
var prevValue = _items[k]; |
|
/** |
* Removes the mapping for the specified key from this map if present |
* |
* @param key |
* Key whose mapping is to be removed from the map |
* @return {any} |
* The previous value associated with <var>key</var>,_value |
* or <code>undefined</code> if there was no mapping for <var>key</var>. |
* (An <code>undefined</code> return can also indicate that the map |
* previously associated <code>undefined</code> with <var>key</var>.) |
* @throws jsx.map#KeyError |
* @public |
*/ |
this.remove = function (key) { |
var k = _getSafeKey(_items, key); |
var prevValue = _items[k]; |
|
if (prevValue) |
{ |
if (_isObjectRef(key)) |
if (prevValue) |
{ |
if (_Bucket.isInstance(prevValue)) |
if (_isObjectRef(key)) |
{ |
prevValue = prevValue.remove(key); |
if (_ValueContainer.isInstance(prevValue)) |
if (_Bucket.isInstance(prevValue)) |
{ |
--_size; |
return prevValue.getValue(); |
prevValue = prevValue.remove(key); |
if (_ValueContainer.isInstance(prevValue)) |
{ |
--_size; |
return prevValue.getValue(); |
} |
|
return prevValue; |
} |
|
return prevValue; |
return void 0; |
} |
|
return void 0; |
delete _items[k]; |
--_size; |
return prevValue && prevValue.getValue(); |
} |
|
delete _items[k]; |
--_size; |
return prevValue && prevValue.getValue(); |
} |
return prevValue; |
}; |
|
return prevValue; |
}; |
/** |
* Removes all of the mappings from this map. |
* The map will be empty after this call returns. |
* |
* @public |
*/ |
this.clear = function () { |
_items = _getDataObject(); |
_size = 0; |
}; |
|
/** |
* Removes all of the mappings from this map. |
* The map will be empty after this call returns. |
* |
* @public |
*/ |
this.clear = function () { |
_items = _getDataObject(); |
_size = 0; |
}; |
/** |
* Returns <code>true</code> if this map maps one or more keys to the specified value. |
* |
* @param value |
* Value whose presence in this map is to be tested |
* @return {boolean} |
* <code>true</code> if this map maps one or more keys |
* to the specified value |
* @public |
*/ |
this.containsValue = function (value) { |
for (var p in _items) |
{ |
var o = _items[p]; |
|
/** |
* Returns <code>true</code> if this map maps one or more keys to the specified value. |
* |
* @param value |
* Value whose presence in this map is to be tested |
* @return {boolean} |
* <code>true</code> if this map maps one or more keys |
* to the specified value |
* @public |
*/ |
this.containsValue = function (value) { |
for (var p in _items) |
{ |
var o = _items[p]; |
if (_ValueContainer.isInstance(o) && o.getValue() === value) |
{ |
return true; |
} |
|
if (_ValueContainer.isInstance(o) && o.getValue() === value) |
{ |
return true; |
if (_Bucket.isInstance(o) && o.containsValue(value)) |
{ |
return true; |
} |
} |
|
if (_Bucket.isInstance(o) && o.containsValue(value)) |
{ |
return true; |
} |
} |
return false; |
}; |
|
return false; |
}; |
/** |
* Returns a list of the keys contained in this map |
* |
* @return {Array} |
* @public |
*/ |
this.keys = function () { |
var a = []; |
|
/** |
* Returns a list of the keys contained in this map |
* |
* @return {Array} |
* @public |
*/ |
this.keys = function () { |
var a = []; |
|
for (var p in _items) |
{ |
var o = _items[p]; |
if (_ValueContainer.isInstance(o)) |
for (var p in _items) |
{ |
a.push(p); |
var o = _items[p]; |
if (_ValueContainer.isInstance(o)) |
{ |
a.push(p); |
} |
else if (_Bucket.isInstance(o)) |
{ |
a.push.apply(a, o.keys()); |
} |
} |
else if (_Bucket.isInstance(o)) |
{ |
a.push.apply(a, o.keys()); |
} |
} |
|
return a; |
}; |
return a; |
}; |
|
/** |
* Returns a list of the values contained in this map |
* |
* @return {Array} |
* @public |
*/ |
this.values = function () { |
var a = []; |
/** |
* Returns a list of the values contained in this map |
* |
* @return {Array} |
* @public |
*/ |
this.values = function () { |
var a = []; |
|
for (var p in _items) |
{ |
var o = _items[p]; |
for (var p in _items) |
{ |
var o = _items[p]; |
|
if (_ValueContainer.isInstance(o)) |
{ |
a.push(o.getValue()); |
if (_ValueContainer.isInstance(o)) |
{ |
a.push(o.getValue()); |
} |
else if (_Bucket.isInstance(o)) |
{ |
a.push.apply(a, o.values()); |
} |
} |
else if (_Bucket.isInstance(o)) |
{ |
a.push.apply(a, o.values()); |
} |
} |
|
return a; |
}; |
return a; |
}; |
|
/** |
* Returns a list of the mappings contained in this map |
* as an {@link Array} of Arrays of key-value pairs. |
* The inner Arrays consist of two elements each, the key |
* and its associated value. |
* |
* @return {Array} |
* @public |
*/ |
this.mappings = function () { |
var a = []; |
/** |
* Returns a list of the mappings contained in this map |
* as an {@link Array} of Arrays of key-value pairs. |
* The inner Arrays consist of two elements each, the key |
* and its associated value. |
* |
* @return {Array} |
* @public |
*/ |
this.mappings = function () { |
var a = []; |
|
for (var p in _items) |
{ |
var o = _items[p]; |
for (var p in _items) |
{ |
var o = _items[p]; |
|
if (_ValueContainer.isInstance(o)) |
{ |
a.push([p, o.getValue()]); |
} |
else if (_Bucket.isInstance(o)) |
{ |
var bucketMappings = o.mappings(); |
for (var i = 0, len = bucketMappings.length; i < len; ++i) |
if (_ValueContainer.isInstance(o)) |
{ |
a.push(bucketMappings[i]); |
a.push([p, o.getValue()]); |
} |
else if (_Bucket.isInstance(o)) |
{ |
var bucketMappings = o.mappings(); |
for (var i = 0, len = bucketMappings.length; i < len; ++i) |
{ |
a.push(bucketMappings[i]); |
} |
} |
} |
} |
|
return a; |
}; |
return a; |
}; |
|
/** |
* Destructs the map so that all closures are released. |
* |
* @public |
*/ |
this.destruct = function () { |
_items = null; |
}; |
/** |
* Destructs the map so that all closures are released. |
* |
* @public |
*/ |
this.destruct = function () { |
_items = null; |
}; |
|
this.strictKeys = !!strictKeys; |
this.strictKeys = !!strictKeys; |
|
if (arguments.length > 0 && map != null) |
{ |
this.putAll(map); |
if (arguments.length > 0 && map != null) |
{ |
this.putAll(map); |
} |
} |
} |
|
return _Map; |
}() |
).extend(null, { |
/** |
* Returns a shallow copy of this map |
* |
* @memberOf jsx.map.Map.prototype |
* @return {jsx.map.Map} |
* @public |
*/ |
clone: function () { |
return new this.constructor(this); |
}, |
return _Map; |
}() |
).extend(null, { |
/** |
* Returns a shallow copy of this map |
* |
* @memberOf jsx.map.Map.prototype |
* @return {jsx.map.Map} |
* @public |
*/ |
clone: function () { |
return new this.constructor(this); |
}, |
|
/** |
* Copies all of the mappings from the specified map to this map. |
* These mappings will replace any mappings that this map had |
* for any of the keys currently in the specified map. |
* |
* @param {jsx.map.Map} map |
* @public |
*/ |
putAll: function (map) { |
if (!this.constructor.isInstance(map)) |
{ |
jsx.throwThis("jsx.InvalidArgumentError"); |
} |
/** |
* Copies all of the mappings from the specified map to this map. |
* These mappings will replace any mappings that this map had |
* for any of the keys currently in the specified map. |
* |
* @param {jsx.map.Map} map |
* @public |
*/ |
putAll: function (map) { |
if (!this.constructor.isInstance(map)) |
{ |
jsx.throwThis("jsx.InvalidArgumentError"); |
} |
|
this.setMaxAliasLength(map.getMaxAliasLength()); |
this.setMaxAliasLength(map.getMaxAliasLength()); |
|
for (var a = map.mappings(), i = a.length; i--;) |
{ |
var o = a[i]; |
for (var a = map.mappings(), i = a.length; i--;) |
{ |
var o = a[i]; |
|
this.put(o[0], o[1]); |
this.put(o[0], o[1]); |
} |
} |
} |
}), { |
), |
{ |
/** |
* Returns <code>true</code> if the argument is a {@link jsx.map#Map Map} |
* |