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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 30× 30× 1× 272× 272× 30× 272× 1× 768× 1× 1× 1× 1× 2× 2× 1× 1× 2× 2× 2× 1× 1× 1× 7× 5× 1× 1× 1× 3× 3× 3× 3× 1× 6× 6× 6× 6× 3× 3× 3× 3× 27× 27× 3× 6× 1× 5× 5× 5× 5× 1× 11× 11× 11× 11× 71× 11× 1× 1× 4× 4× 4× 1× 2× 2× 2× 1× 4× 2× 2× 2× 2× 1× 1× 1× 1× 1× 23× 23× 1× 17× 17× 1× 531× 1× 21× 21× 1× 1× 1× 1× 1× 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", "./LinkedNodeList", "../Exceptions/ArgumentNullException", "./Enumeration/Enumerator", "./Enumeration/EmptyEnumerator", "../Disposable/dispose", "../Compare", "./CollectionBase"], factory); } })(function (require, exports) { "use strict"; var LinkedNodeList_1 = require("./LinkedNodeList"); var ArgumentNullException_1 = require("../Exceptions/ArgumentNullException"); var Enumerator_1 = require("./Enumeration/Enumerator"); var EmptyEnumerator_1 = require("./Enumeration/EmptyEnumerator"); var dispose_1 = require("../Disposable/dispose"); var Compare_1 = require("../Compare"); var CollectionBase_1 = require("./CollectionBase"); var OTHER = 'other'; var SetBase = (function (_super) { __extends(SetBase, _super); function SetBase(source) { _super.call(this, null, Compare_1.areEqual); this._importEntries(source); } SetBase.prototype._getSet = function () { var s = this._set; if (!s) this._set = s = new LinkedNodeList_1.LinkedNodeList(); return s; }; SetBase.prototype.getCount = function () { return this._set ? this._set.unsafeCount : 0; }; SetBase.prototype.exceptWith = function (other) { var _ = this; Iif (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); Enumerator_1.forEach(other, function (v) { Eif (_._removeInternal(v)) _._incrementModified(); }); _._signalModification(); }; SetBase.prototype.intersectWith = function (other) { Iif (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); var _ = this; if (other instanceof SetBase) { var s = _._set; Eif (s) s.forEach(function (n) { if (!other.contains(n.value) && _._removeInternal(n.value)) _._incrementModified(); }); _._signalModification(); } else { dispose_1.using(_.newUsing(other), function (o) { return _.intersectWith(o); }); } }; SetBase.prototype.isProperSubsetOf = function (other) { var _this = this; Iif (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); return other instanceof SetBase ? other.isProperSupersetOf(this) : dispose_1.using(this.newUsing(other), function (o) { return o.isProperSupersetOf(_this); }); }; SetBase.prototype.isProperSupersetOf = function (other) { var _this = this; Iif (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); var result = true, count; if (other instanceof SetBase) { result = this.isSupersetOf(other); count = other.getCount(); } else { count = dispose_1.using(this.newUsing(), function (o) { Enumerator_1.forEach(other, function (v) { o.add(v); return result = _this.contains(v); }); return o.getCount(); }); } return result && this.getCount() > count; }; SetBase.prototype.isSubsetOf = function (other) { var _this = this; Iif (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); return other instanceof SetBase ? other.isSupersetOf(this) : dispose_1.using(this.newUsing(other), function (o) { return o.isSupersetOf(_this); }); }; SetBase.prototype.isSupersetOf = function (other) { var _this = this; Iif (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); var result = true; Enumerator_1.forEach(other, function (v) { return result = _this.contains(v); }); return result; }; SetBase.prototype.overlaps = function (other) { var _this = this; if (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); var result = false; Enumerator_1.forEach(other, function (v) { return !(result = _this.contains(v)); }); return result; }; SetBase.prototype.setEquals = function (other) { Iif (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); return this.getCount() == (other instanceof SetBase ? other.getCount() : dispose_1.using(this.newUsing(other), function (o) { return o.getCount(); })) && this.isSubsetOf(other); }; SetBase.prototype.symmetricExceptWith = function (other) { Iif (!other) throw new ArgumentNullException_1.ArgumentNullException(OTHER); var _ = this; if (other instanceof SetBase) { Enumerator_1.forEach(other, function (v) { if (_.contains(v)) { Eif (_._removeInternal(v)) _._incrementModified(); } else { Eif (_._addInternal(v)) _._incrementModified(); } }); _._signalModification(); } else { dispose_1.using(this.newUsing(other), function (o) { return _.symmetricExceptWith(o); }); } }; SetBase.prototype.unionWith = function (other) { this.importEntries(other); }; SetBase.prototype._clearInternal = function () { var s = this._set; return s ? s.clear() : 0; }; SetBase.prototype._onDispose = function () { _super.prototype._onDispose.call(this); this._set = null; }; SetBase.prototype.contains = function (item) { return !(!this.getCount() || !this._getNode(item)); }; SetBase.prototype.getEnumerator = function () { var s = this._set; return s && this.getCount() ? LinkedNodeList_1.LinkedNodeList.valueEnumeratorFrom(s) : EmptyEnumerator_1.EmptyEnumerator; }; SetBase.prototype.forEach = function (action, useCopy) { if (useCopy === void 0) { useCopy = false; } return useCopy ? _super.prototype.forEach.call(this, action, useCopy) : this._set.forEach(function (node, i) { return action(node.value, i); }); }; SetBase.prototype._removeNode = function (node) { if (!node) return false; return this.remove(node.value) != 0; }; SetBase.prototype.removeFirst = function () { var s = this._set; return this._removeNode(s && s.first); }; SetBase.prototype.removeLast = function () { var s = this._set; return this._removeNode(s && s.last); }; return SetBase; }(CollectionBase_1.CollectionBase)); exports.SetBase = SetBase; function wipe(map, depth) { if (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 = SetBase; }); //# sourceMappingURL=SetBase.js.map |