# all files / TypeScript.NET/source/System/Collections/ Set.js

88% Statements 66/75
72.55% Branches 37/51
100% Functions 13/13
92.65% Lines 63/68

    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

    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    30×

    1×
    17×

    1×
    345×
    345×
    272×
    272×

    272×
    272×
    272×
    30×
    272×
    90×
    272×
    272×
    272×
    272×

    73×

    1×
    23×
    23×

    1×
    17×
    17×

    1×
    489×
    489×

    1×
    40×
    40×

    40×
    40×
    40×
    40×
    40×
    40×

    1×

    1×
    1×
    245×
    245×
    78×
    222×
    222×
    222×
    222×

    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", "../Types", "../Exceptions/ArgumentException", "./SetBase"], factory);
        }
    })(function (require, exports) {
        "use strict";
        var Types_1 = require("../Types");
        var ArgumentException_1 = require("../Exceptions/ArgumentException");
        var SetBase_1 = require("./SetBase");
        var OTHER = 'other';
        var Set = (function (_super) {
            __extends(Set, _super);
            function Set() {
                _super.apply(this, arguments);
            }
            Set.prototype.newUsing = function (source) {
                return new Set(source);
            };
            Set.prototype._addInternal = function (item) {
                var _ = this;
                if (!_.contains(item)) {
                    var type = typeof item;
                    Iif (!Types_1.Type.isPrimitive(type))
                        throw new ArgumentException_1.ArgumentException("item", "A Set can only index primitives.  Complex objects require a HashSet.");
                    var r = _._registry;
                    var t = r && r[type];
                    if (!r)
                        _._registry = r = {};
                    if (!t)
                        r[type] = t = {};
                    var node = { value: item };
                    _._getSet().addNode(node);
                    t[item] = node;
                    return true;
                }
                return false;
            };
            Set.prototype._clearInternal = function () {
                wipe(this._registry, 2);
                return _super.prototype._clearInternal.call(this);
            };
            Set.prototype._onDispose = function () {
                _super.prototype._onDispose.call(this);
                this._registry = null;
            };
            Set.prototype._getNode = function (item) {
                var r = this._registry, t = r && r[typeof item];
                return t && t[item];
            };
            Set.prototype._removeInternal = function (item, max) {
                if (max === void 0) { max = Infinity; }
                Iif (max === 0)
                    return 0;
                var r = this._registry, t = r && r[typeof item], node = t && t[item];
                Eif (node) {
                    delete t[item];
                    var s = this._set;
                    Eif (s && s.removeNode(node)) {
                        return 1;
                    }
                }
                return 0;
            };
            return Set;
        }(SetBase_1.SetBase));
        exports.Set = Set;
        function wipe(map, depth) {
            Iif (depth === void 0) { depth = 1; }
            if (map && depth) {
                for (var _i = 0, _a = Object.keys(map); _i < _a.length; _i++) {
                    var key = _a[_i];
                    var v = map[key];
                    delete map[key];
                    wipe(v, depth - 1);
                }
            }
        }
        Object.defineProperty(exports, "__esModule", { value: true });
        exports.default = Set;
    });
    //# sourceMappingURL=Set.js.map