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