typescript-dotnet-core
Version:
A the core classes and utilities of a JavaScript-Friendly .NET Based TypeScript Library.
7 lines (6 loc) • 4.32 kB
JavaScript
"use strict";
/*!
* @author electricessence / https://github.com/electricessence/
* Licensing: MIT https://github.com/electricessence/TypeScript.NET-Core/blob/master/LICENSE.md
*/Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),LinkedNodeList_1=require("./LinkedNodeList"),ArgumentNullException_1=require("../Exceptions/ArgumentNullException"),Enumerator_1=require("./Enumeration/Enumerator"),EmptyEnumerator_1=require("./Enumeration/EmptyEnumerator"),dispose_1=require("../Disposable/dispose"),Compare_1=require("../Compare"),CollectionBase_1=require("./CollectionBase"),VOID0=void 0,OTHER="other",SetBase=function(r){function i(t){var e=r.call(this,VOID0,Compare_1.areEqual)||this;return e._importEntries(t),e}return tslib_1.__extends(i,r),i.prototype._getSet=function(){var t=this._set;return t||(this._set=t=new LinkedNodeList_1.default),t},i.prototype.getCount=function(){return this._set?this._set.unsafeCount:0},i.prototype.addMissing=function(t){return!this.contains(t)&&(this.add(t),!0)},i.prototype.exceptWith=function(t){var e=this;if(!t)throw new ArgumentNullException_1.default(OTHER);Enumerator_1.forEach(t,function(t){e._removeInternal(t)&&e._incrementModified()}),e._signalModification()},i.prototype.intersectWith=function(e){if(!e)throw new ArgumentNullException_1.default(OTHER);var n=this;if(e instanceof i){var t=n._set;t&&t.forEach(function(t){!e.contains(t.value)&&n._removeInternal(t.value)&&n._incrementModified()},!0),n._signalModification()}else dispose_1.using(n.newUsing(e),function(t){return n.intersectWith(t)})},i.prototype.isProperSubsetOf=function(t){var e=this;if(!t)throw new ArgumentNullException_1.default(OTHER);return t instanceof i?t.isProperSupersetOf(this):dispose_1.using(this.newUsing(t),function(t){return t.isProperSupersetOf(e)})},i.prototype.isProperSupersetOf=function(t){var n=this;if(!t)throw new ArgumentNullException_1.default(OTHER);var e,r=!0;return e=t instanceof i?(r=this.isSupersetOf(t),t.getCount()):dispose_1.using(this.newUsing(),function(e){return Enumerator_1.forEach(t,function(t){return e.add(t),r=n.contains(t)}),e.getCount()}),r&&this.getCount()>e},i.prototype.isSubsetOf=function(t){var e=this;if(!t)throw new ArgumentNullException_1.default(OTHER);return t instanceof i?t.isSupersetOf(this):dispose_1.using(this.newUsing(t),function(t){return t.isSupersetOf(e)})},i.prototype.isSupersetOf=function(t){var e=this;if(!t)throw new ArgumentNullException_1.default(OTHER);var n=!0;return Enumerator_1.forEach(t,function(t){return n=e.contains(t)}),n},i.prototype.overlaps=function(t){var e=this;if(!t)throw new ArgumentNullException_1.default(OTHER);var n=!1;return Enumerator_1.forEach(t,function(t){return!(n=e.contains(t))}),n},i.prototype.setEquals=function(t){if(!t)throw new ArgumentNullException_1.default(OTHER);return this.getCount()==(t instanceof i?t.getCount():dispose_1.using(this.newUsing(t),function(t){return t.getCount()}))&&this.isSubsetOf(t)},i.prototype.symmetricExceptWith=function(t){if(!t)throw new ArgumentNullException_1.default(OTHER);var e=this;t instanceof i?(Enumerator_1.forEach(t,function(t){e.contains(t)?e._removeInternal(t)&&e._incrementModified():e._addInternal(t)&&e._incrementModified()}),e._signalModification()):dispose_1.using(this.newUsing(t),function(t){return e.symmetricExceptWith(t)})},i.prototype.unionWith=function(t){this.importEntries(t)},i.prototype._clearInternal=function(){var t=this._set;return t?t.clear():0},i.prototype._onDispose=function(){r.prototype._onDispose.call(this),this._set=null},i.prototype.contains=function(t){return!(!this.getCount()||!this._getNode(t))},i.prototype.getEnumerator=function(){var t=this;t.throwIfDisposed();var e=t._set;return e&&t.getCount()?LinkedNodeList_1.default.valueEnumeratorFrom(e):EmptyEnumerator_1.default},i.prototype.forEach=function(n,t){return t?r.prototype.forEach.call(this,n,t):this._set?this._set.forEach(function(t,e){return n(t.value,e)}):0},i.prototype._removeNode=function(t){return!!t&&0!=this.remove(t.value)},i.prototype.removeFirst=function(){var t=this._set;return this._removeNode(t&&t.first)},i.prototype.removeLast=function(){var t=this._set;return this._removeNode(t&&t.last)},i}(CollectionBase_1.default);exports.SetBase=SetBase,exports.default=SetBase;
//# sourceMappingURL=SetBase.js.map