/*!
 * @author electricessence / https://github.com/electricessence/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 */
!function(t){if("object"==typeof module&&"object"==typeof module.exports){var e=t(require,exports);void 0!==e&&(module.exports=e)}else"function"==typeof define&&define.amd&&define(["require","exports","../Types","./LinkedNodeList","../Exceptions/ArgumentException","../Exceptions/ArgumentNullException","./Enumeration/forEach","./Enumeration/Enumerator","../Disposable/Utility"],t)}(function(t,e){"use strict";function n(t,e){if(void 0===e&&(e=1),t&&e)for(var r=0,o=Object.keys(t);r<o.length;r++){var i=o[r],u=t[i];delete t[i],n(u,e-1)}}var r=t("../Types"),o=t("./LinkedNodeList"),i=t("../Exceptions/ArgumentException"),u=t("../Exceptions/ArgumentNullException"),s=t("./Enumeration/forEach"),f=t("./Enumeration/Enumerator"),a=t("../Disposable/Utility"),c="other",p=function(){function t(t){this._count=0,t&&this.unionWith(t)}return t.prototype._getSet=function(){var t=this._set;return t||(this._set=t=new o["default"]),t},Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isReadOnly",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.exceptWith=function(t){var e=this;if(!t)throw new u["default"](c);s["default"](t,function(t){e.remove(t)})},t.prototype.intersectWith=function(e){var n=this;if(!e)throw new u["default"](c);if(e instanceof t){var r=this._set;r&&r.forEach(function(t){e.contains(t.value)||n.remove(t.value)})}else a.using(new t(e),function(t){return n.intersectWith(t)})},t.prototype.isProperSubsetOf=function(e){var n=this;if(!e)throw new u["default"](c);return e instanceof t?e.isProperSupersetOf(this):a.using(new t(e),function(t){return t.isProperSupersetOf(n)})},t.prototype.isProperSupersetOf=function(e){var n=this;if(!e)throw new u["default"](c);var r,o=!0;return e instanceof t?(o=this.isSupersetOf(e),r=e._count):a.using(new t,function(t){s["default"](e,function(e){return t.add(e),o=n.contains(e)}),r=t._count}),o&&this._count>r},t.prototype.isSubsetOf=function(e){var n=this;if(!e)throw new u["default"](c);return e instanceof t?e.isSupersetOf(this):a.using(new t(e),function(t){return t.isSupersetOf(n)})},t.prototype.isSupersetOf=function(t){var e=this;if(!t)throw new u["default"](c);var n=!0;return s["default"](t,function(t){return n=e.contains(t)}),n},t.prototype.overlaps=function(t){var e=this;if(!t)throw new u["default"](c);var n=!1;return s["default"](t,function(t){return!(n=e.contains(t))}),n},t.prototype.setEquals=function(e){if(!e)throw new u["default"](c);return this._count==(e instanceof t?e._count:a.using(new t(e),function(t){return t._count}))&&this.isSubsetOf(e)},t.prototype.symmetricExceptWith=function(e){var n=this;if(!e)throw new u["default"](c);e instanceof t?s["default"](e,function(t){n.contains(t)?n.remove(t):n.add(t)}):a.using(new t(e),function(t){return n.symmetricExceptWith(t)})},t.prototype.unionWith=function(t){var e=this;s["default"](t,function(t){e.add(t)})},t.prototype.add=function(t){if(!this.contains(t)){var e=typeof t;if(!r["default"].isPrimitive(e))throw new i["default"]("item","A Set can only index primitives.  Complex objects require a HashSet.");var n=this._registry,o=n&&n[e];n||(this._registry=n={}),o||(n[e]=o={});var u={value:t};this._getSet().addNode(u),o[t]=u,++this._count}},t.prototype.clear=function(){var t=this;t._count=0,n(t._registry,2);var e=t._set;return e?e.clear():0},t.prototype.dispose=function(){this.clear(),this._set=null,this._registry=null},t.prototype._getNode=function(t){var e=this._registry,n=e&&e[typeof t];return n&&n[t]},t.prototype.contains=function(t){return!(!this._count||!this._getNode(t))},t.prototype.copyTo=function(t,e){if(void 0===e&&(e=0),!t)throw new u["default"]("array");var n=this._set,r=this._count;if(!n||!r)return t;var i=e+r;return t.length<i&&(t.length=i),o["default"].copyValues(n,t,e)},t.prototype.toArray=function(){var t=this._set;return t?t.map(function(t){return t.value}):[]},t.prototype.remove=function(t){var e=this._registry,n=e&&e[typeof t],r=n&&n[t];if(r){delete n[t];var o=this._set;if(o&&o.removeNode(r))return--this._count,1}return 0},t.prototype.getEnumerator=function(){var t=this._set;return t&&this._count?o["default"].valueEnumeratorFrom(t):f.empty},t}();Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=p});
//# sourceMappingURL=Set.js.map
