UNPKG

ts-collection

Version:

This is re-write of the java collection classes in typescript. There is some tweak as typescript templates are not as equivalent as Java.

99 lines (98 loc) 4.41 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 NavigableSubMap_1 = require("../treemaputil/NavigableSubMap"); var Collections_1 = require("../Collections"); var illegalargumentexception_1 = require("../../lang/illegalargumentexception"); var AscendingSubMap_1 = require("./AscendingSubMap"); var DescendingSubMapKeyIterator_1 = require("./DescendingSubMapKeyIterator"); var DescendingSubMap = /** @class */ (function (_super) { __extends(DescendingSubMap, _super); function DescendingSubMap(map, fromStart, lo, loInclusive, toEnd, hi, hiInclusive) { var _this = _super.call(this, map, fromStart, lo, loInclusive, toEnd, hi, hiInclusive) || this; _this.m_Comparator = null; _this.m_Comparator = Collections_1.Collections.reverseOrder(_this.map.comparator()); return _this; } DescendingSubMap.prototype.comparator = function () { return this.m_Comparator; }; DescendingSubMap.prototype.subMap = function (fromKey, fromInclusiveOrToKey, param3, param4) { var fromInclusive = false; var toKey = undefined; var toInclusive = false; if (typeof fromInclusiveOrToKey === 'boolean') { fromInclusive = fromInclusiveOrToKey; toKey = param3; toInclusive = param4; } else { toKey = fromInclusiveOrToKey; fromInclusive = false; toInclusive = false; } if (!this.inRange(fromKey, fromInclusive)) { throw new illegalargumentexception_1.IllegalArgumentException(); } if (!this.inRange(toKey, toInclusive)) { throw new illegalargumentexception_1.IllegalArgumentException(); } return new DescendingSubMap(this.map, false, toKey, toInclusive, false, fromKey, fromInclusive); }; DescendingSubMap.prototype.headMap = function (toKey, inclusive) { if (!this.inRange(toKey, inclusive)) { throw new illegalargumentexception_1.IllegalArgumentException(); } return new DescendingSubMap(this.map, false, toKey, this.loInclusive, this.toEnd, this.hi, this.hiInclusive); }; DescendingSubMap.prototype.tailMap = function (fromKey, inclusive) { if (!this.inRange(fromKey, inclusive)) { throw new illegalargumentexception_1.IllegalArgumentException(); } return new DescendingSubMap(this.map, this.fromStart, this.lo, this.loInclusive, false, fromKey, inclusive); }; DescendingSubMap.prototype.descendingMap = function () { return new AscendingSubMap_1.AscendingSubMap(this.map, this.fromStart, this.lo, this.loInclusive, this.toEnd, this.hi, this.hiInclusive); }; DescendingSubMap.prototype.keyIterator = function () { return new DescendingSubMapKeyIterator_1.DescendingSubMapKeyIterator(this.map, this.absHighest(), this.absLowFence()); }; DescendingSubMap.prototype.descendingKeyIterator = function () { return null; }; DescendingSubMap.prototype.entrySet = function () { return null; }; DescendingSubMap.prototype.subLowest = function () { return this.absHighest(); }; DescendingSubMap.prototype.subHighest = function () { return this.absLowest(); }; DescendingSubMap.prototype.subCeiling = function (key) { return this.absFloor(key); }; DescendingSubMap.prototype.subHigher = function (key) { return this.absLower(key); }; DescendingSubMap.prototype.subFloor = function (key) { return this.absCeiling(key); }; DescendingSubMap.prototype.subLower = function (key) { return this.absHigher(key); }; return DescendingSubMap; }(NavigableSubMap_1.NavigableSubMap)); exports.DescendingSubMap = DescendingSubMap;