# all files / TypeScript.NET/source/System/Collections/Dictionaries/ StringKeyDictionary.js

56.32% Statements 49/87
40.35% Branches 23/57
58.82% Functions 10/17
57.32% Lines 47/82

    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
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120

    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    54×
    3×
    51×

    1×

    1×
    77×
    3×
    74×

    1×
    36×
    36×
    36×
    18×
    18×
    18×

    18×
    18×
    18×

    36×

    1×

    1×

    1×

    1×

    1×
    54×

    1×

    1×
    1×
    1×

     /*!
     * @author electricessence / https://github.com/electricessence/
     * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
     */
    var __extends = (this && this.__extends) || function (d, b) {
        for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
    (function (factory) {
        Eif (typeof module === 'object' && typeof module.exports === 'object') {
            var v = factory(require, exports); Iif (v !== undefined) module.exports = v;
        }
        else if (typeof define === 'function' && define.amd) {
            define(["require", "exports", "../../Compare", "./DictionaryBase"], factory);
        }
    })(function (require, exports) {
        "use strict";
        var Compare_1 = require("../../Compare");
        var DictionaryBase_1 = require("./DictionaryBase");
        var VOID0 = void 0;
        var StringKeyDictionary = (function (_super) {
            __extends(StringKeyDictionary, _super);
            function StringKeyDictionary() {
                _super.apply(this, arguments);
                this._count = 0;
                this._map = {};
            }
            StringKeyDictionary.prototype._getEntry = function (key) {
                return !this.containsKey(key)
                    ? null : {
                    key: key,
                    value: this.getValue(key)
                };
            };
            StringKeyDictionary.prototype.containsKey = function (key) {
                if (key === null || key === VOID0 || !this._count)
                    return false;
                return (key) in (this._map);
            };
            StringKeyDictionary.prototype.containsValue = function (value) {
                if (!this._count)
                    return false;
                var map = this._map, equal = Compare_1.areEqual;
                for (var key in map) {
                    if (map.hasOwnProperty(key) && equal(map[key], value))
                        return true;
                }
                return false;
            };
            StringKeyDictionary.prototype.getValue = function (key) {
                if (key === null || key === VOID0 || !this._count)
                    return VOID0;
                return this._map[key];
            };
            StringKeyDictionary.prototype._setValueInternal = function (key, value) {
                var _ = this, map = _._map, old = map[key];
                Eif (old !== value) {
                    if (value === VOID0) {
                        Eif ((key) in (map)) {
                            delete map[key];
                            _._count--;
                        }
                    }
                    else {
                        Eif (!map.hasOwnProperty(key))
                            _._count++;
                        map[key] = value;
                    }
                    return true;
                }
                return false;
            };
            StringKeyDictionary.prototype.importMap = function (values) {
                var _ = this;
                return _.handleUpdate(function () {
                    var changed = false;
                    for (var key in values) {
                        if (values.hasOwnProperty(key) && _.setValue(key, values[key]))
                            changed = true;
                    }
                    return changed;
                });
            };
            StringKeyDictionary.prototype.toMap = function (selector) {
                var _ = this, result = {};
                if (_._count)
                    for (var key in _._map) {
                        if (_._map.hasOwnProperty(key)) {
                            var value = _._map[key];
                            if (selector)
                                value = selector(key, value);
                            if (value !== VOID0)
                                result[key] = value;
                        }
                    }
                return result;
            };
            StringKeyDictionary.prototype.getKeys = function () {
                return Object.keys(this._map);
            };
            StringKeyDictionary.prototype.getValues = function () {
                if (!this._count)
                    return [];
                var result = Object.keys(this._map);
                for (var i = 0, len = result.length; i < len; i++) {
                    result[i] = this._map[result[i]];
                }
                return result;
            };
            StringKeyDictionary.prototype.getCount = function () {
                return this._count;
            };
            return StringKeyDictionary;
        }(DictionaryBase_1.DictionaryBase));
        exports.StringKeyDictionary = StringKeyDictionary;
        Object.defineProperty(exports, "__esModule", { value: true });
        exports.default = StringKeyDictionary;
    });
    //# sourceMappingURL=StringKeyDictionary.js.map