UNPKG

ecol

Version:
118 lines 4.71 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { 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 extendStatics(d, b); }; 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 HashMap_1 = require("tstl/container/HashMap"); var CollectionEvent_1 = require("../basic/CollectionEvent"); var EventDispatcher_1 = require("../basic/EventDispatcher"); require("./internal"); var HashMapCollection = /** @class */ (function (_super) { __extends(HashMapCollection, _super); function HashMapCollection() { var _this = _super !== null && _super.apply(this, arguments) || this; /** * @hidden */ _this.dispatcher_ = new EventDispatcher_1.EventDispatcher(); return _this; } /* --------------------------------------------------------- CONSTRUCTORS --------------------------------------------------------- */ // using super.constructor; HashMapCollection.prototype.clear = function () { var first = this.begin(); var last = this.end(); _super.prototype.clear.call(this); this.dispatchEvent(new CollectionEvent_1.CollectionEvent("erase", first, last)); }; /* --------------------------------------------------------- ELEMENTS I/O --------------------------------------------------------- */ /** * @hidden */ HashMapCollection.prototype._Handle_insert = function (first, last) { _super.prototype._Handle_insert.call(this, first, last); this.dispatchEvent(new CollectionEvent_1.CollectionEvent("insert", first, last)); }; /** * @hidden */ HashMapCollection.prototype._Handle_erase = function (first, last) { this._Handle_erase(first, last); this.dispatchEvent(new CollectionEvent_1.CollectionEvent("erase", first, last)); }; /* ========================================================= EVENT DISPATCHER - NOTIFIERS - ACCESSORS ============================================================ NOTIFIERS --------------------------------------------------------- */ /** * @inheritDoc */ HashMapCollection.prototype.dispatchEvent = function (event) { if (this.dispatcher_) this.dispatcher_.dispatchEvent(event); }; HashMapCollection.prototype.refresh = function (first, last) { if (first === undefined) { first = this.begin(); last = this.end(); } else if (last === undefined) last = first.next(); this.dispatchEvent(new CollectionEvent_1.CollectionEvent("refresh", first, last)); }; /* --------------------------------------------------------- ACCESSORS -------------------------------------------------------- */ /** * @inheritDoc */ HashMapCollection.prototype.hasEventListener = function (type) { return this.dispatcher_.hasEventListener(type); }; /** * @inheritDoc */ HashMapCollection.prototype.addEventListener = function (type, listener) { this.dispatcher_.addEventListener(type, listener); }; /** * @inheritDoc */ HashMapCollection.prototype.removeEventListener = function (type, listener) { this.dispatcher_.removeEventListener(type, listener); }; return HashMapCollection; }(HashMap_1.HashMap)); exports.HashMapCollection = HashMapCollection; (function (HashMapCollection) { HashMapCollection.Event = CollectionEvent_1.CollectionEvent; HashMapCollection.Iterator = HashMap_1.HashMap.Iterator; HashMapCollection.ReverseIterator = HashMap_1.HashMap.ReverseIterator; })(HashMapCollection = exports.HashMapCollection || (exports.HashMapCollection = {})); exports.HashMapCollection = HashMapCollection; var old_swap = HashMap_1.HashMap.prototype.swap; HashMap_1.HashMap.prototype.swap = function (obj) { old_swap.call(this, obj); if (this instanceof HashMapCollection) this.refresh(); if (obj instanceof HashMapCollection) obj.refresh(); }; //# sourceMappingURL=HashMapCollection.js.map