all files / export/pdf-base/ dictionary.js

85.96% Statements 49/57
75% Branches 24/32
100% Functions 12/12
85.96% Lines 49/57
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89   121× 121×     310×     310× 310× 310× 310× 310×                                                       1814×     1814× 1814× 308×   1506×          
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;
});