define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TemporaryDictionary = (function () {
function TemporaryDictionary() {
this.mKeys = [];
this.mValues = [];
}
TemporaryDictionary.prototype.size = function () {
return this.mKeys.length;
};
TemporaryDictionary.prototype.add = function (key, value) {
Iif (key === undefined || key === null || value === undefined || value === null) {
throw new ReferenceError('Provided key or value is not valid.');
}
var index = this.mKeys.indexOf(key);
Eif (index < 0) {
this.mKeys.push(key);
this.mValues.push(value);
return 1;
}
else {
throw new RangeError('An item with the same key has already been added.');
}
};
TemporaryDictionary.prototype.keys = function () {
return this.mKeys;
};
TemporaryDictionary.prototype.values = function () {
return this.mValues;
};
TemporaryDictionary.prototype.getValue = function (key) {
Iif (key === undefined || key === null) {
throw new ReferenceError('Provided key is not valid.');
}
var index = this.mKeys.indexOf(key);
Iif (index < 0) {
throw new RangeError('No item with the specified key has been added.');
}
else {
return this.mValues[index];
}
};
TemporaryDictionary.prototype.setValue = function (key, value) {
Iif (key === undefined || key === null) {
throw new ReferenceError('Provided key is not valid.');
}
var index = this.mKeys.indexOf(key);
if (index < 0) {
this.mKeys.push(key);
this.mValues.push(value);
}
else {
this.mValues[index] = value;
}
};
TemporaryDictionary.prototype.remove = function (key) {
Iif (key === undefined || key === null) {
throw new ReferenceError('Provided key is not valid.');
}
var index = this.mKeys.indexOf(key);
Iif (index < 0) {
throw new RangeError('No item with the specified key has been added.');
}
else {
this.mKeys.splice(index, 1);
this.mValues.splice(index, 1);
return true;
}
};
TemporaryDictionary.prototype.containsKey = function (key) {
Iif (key === undefined || key === null) {
throw new ReferenceError('Provided key is not valid.');
}
var index = this.mKeys.indexOf(key);
if (index < 0) {
return false;
}
return true;
};
TemporaryDictionary.prototype.clear = function () {
this.mKeys = [];
this.mValues = [];
};
return TemporaryDictionary;
}());
exports.TemporaryDictionary = TemporaryDictionary;
});
|