UNPKG

econ

Version:
178 lines 6.47 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var std = require("tstl"); var CollectionEvent_1 = require("../basic/CollectionEvent"); var EventDispatcher_1 = require("../basic/EventDispatcher"); var VectorBoolean = /** @class */ (function (_super) { __extends(VectorBoolean, _super); function VectorBoolean() { var _this = _super !== null && _super.apply(this, arguments) || this; /** * @hidden */ _this.dispatcher_ = new EventDispatcher_1.EventDispatcher(); return _this; } /* --------------------------------------------------------- CONSTRUCTORS --------------------------------------------------------- */ // using super.constructor; VectorBoolean.prototype.clear = function () { var first = this.begin(); var last = this.end(); this._Notify_erase(first, last); _super.prototype.clear.call(this); }; /* ========================================================= ELEMENTS I/O - INSERT - ERASE - REFRESH ============================================================ INSERT --------------------------------------------------------- */ /** * @inheritdoc */ VectorBoolean.prototype.push_back = function (val) { _super.prototype.push.call(this, val); this._Notify_insert(this.end().prev(), this.end()); }; /** * @hidden */ VectorBoolean.prototype._Insert_by_repeating_val = function (pos, n, val) { var ret = _super.prototype._Insert_by_repeating_val.call(this, pos, n, val); this._Notify_insert(pos, pos.advance(n)); return ret; }; /** * @hidden */ VectorBoolean.prototype._Insert_by_range = function (pos, first, last) { var n = this.size(); var ret = _super.prototype._Insert_by_range.call(this, pos, first, last); n = this.size() - n; this._Notify_insert(ret, ret.advance(n)); return ret; }; /* --------------------------------------------------------- ERASE --------------------------------------------------------- */ /** * @inheritdoc */ VectorBoolean.prototype.pop_back = function () { this._Notify_erase(this.end().prev(), this.end()); _super.prototype.pop_back.call(this); }; /** * @hidden */ VectorBoolean.prototype._Erase_by_range = function (first, last) { this._Notify_erase(first, last); return _super.prototype._Erase_by_range.call(this, first, last); }; /* --------------------------------------------------------- REFRESH --------------------------------------------------------- */ /** * @inheritDoc */ VectorBoolean.prototype.set = function (index, val) { _super.prototype.set.call(this, index, val); this.refresh(this.begin().advance(index)); }; /** * @inheritDoc */ VectorBoolean.prototype.flip = function () { _super.prototype.flip.call(this); this.refresh(); }; VectorBoolean.prototype.refresh = function (first, last) { if (first === void 0) { first = null; } if (last === void 0) { last = null; } if (first == null) { first = this.begin(); last = this.end(); } else if (last == null) last = first.next(); this.dispatchEvent(new CollectionEvent_1.CollectionEvent("refresh", first, last)); }; /* ========================================================= EVENT DISPATCHER - NOTIFIERS - ACCESSORS ============================================================ NOTIFIERS --------------------------------------------------------- */ /** * @inheritdoc */ VectorBoolean.prototype.dispatchEvent = function (event) { if (this.dispatcher_) this.dispatcher_.dispatchEvent(event); }; /** * @hidden */ VectorBoolean.prototype._Notify_insert = function (first, last) { this.dispatchEvent(new CollectionEvent_1.CollectionEvent("insert", first, last)); }; /** * @hidden */ VectorBoolean.prototype._Notify_erase = function (first, last) { this.dispatchEvent(new CollectionEvent_1.CollectionEvent("erase", first, last)); }; /* --------------------------------------------------------- ACCESSORS --------------------------------------------------------- */ /** * @inheritdoc */ VectorBoolean.prototype.hasEventListener = function (type) { return this.dispatcher_.hasEventListener(type); }; /** * @inheritdoc */ VectorBoolean.prototype.addEventListener = function (type, listener) { this.dispatcher_.addEventListener(type, listener); }; /** * @inheritdoc */ VectorBoolean.prototype.removeEventListener = function (type, listener) { this.dispatcher_.removeEventListener(type, listener); }; return VectorBoolean; }(std.VectorBoolean)); exports.VectorBoolean = VectorBoolean; (function (VectorBoolean) { VectorBoolean.Event = CollectionEvent_1.CollectionEvent; VectorBoolean.Iterator = std.VectorBoolean.Iterator; VectorBoolean.ReverseIterator = std.VectorBoolean.ReverseIterator; })(VectorBoolean = exports.VectorBoolean || (exports.VectorBoolean = {})); exports.VectorBoolean = VectorBoolean; var old_swap = std.VectorBoolean.prototype.swap; std.VectorBoolean.prototype.swap = function (obj) { old_swap.call(this, obj); if (this instanceof VectorBoolean) this.refresh(); if (obj instanceof VectorBoolean) obj.refresh(); }; //# sourceMappingURL=VectorBoolean.js.map