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.

101 lines (100 loc) 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 NavigableSubSet_1 = require("./NavigableSubSet"); var Collections_1 = require("../Collections"); var illegalargumentexception_1 = require("../../lang/illegalargumentexception"); var AscendingSubSet_1 = require("./AscendingSubSet"); var DescendingSubSetIterator_1 = require("./DescendingSubSetIterator"); var DescendingSubSet = /** @class */ (function (_super) { __extends(DescendingSubSet, _super); function DescendingSubSet(treeSet, fromStart, lo, loInclusive, toEnd, hi, hiInclusive) { var _this = _super.call(this, treeSet, fromStart, lo, loInclusive, toEnd, hi, hiInclusive) || this; _this.reverseComparator = Collections_1.Collections.reverseOrder(_this.m_TreeSet.comparator()); return _this; } DescendingSubSet.prototype.comparator = function () { return this.reverseComparator; }; DescendingSubSet.prototype.subSet = function (fromElement, fromInclusiveOrToElement, param3, param4) { var fromInclusive; var toElement = null; var toInclusive; if (typeof fromInclusiveOrToElement === 'boolean') { fromInclusive = fromInclusiveOrToElement; toElement = param3; toInclusive = param4; } else { toElement = fromInclusiveOrToElement; toInclusive = true; fromInclusive = false; } if (!this.inRange(fromElement, fromInclusive)) { throw new illegalargumentexception_1.IllegalArgumentException('fromKey out of range'); } if (!this.inRange(toElement, toInclusive)) { throw new illegalargumentexception_1.IllegalArgumentException('toKey out of range'); } return new DescendingSubSet(this.m_TreeSet, false, toElement, toInclusive, false, fromElement, fromInclusive); }; DescendingSubSet.prototype.headSet = function (toElement, inclusive) { if (inclusive === undefined) { inclusive = false; } if (!this.inRange(toElement, inclusive)) { throw new illegalargumentexception_1.IllegalArgumentException('toKey out of range'); } return new DescendingSubSet(this.m_TreeSet, false, toElement, inclusive, this.m_ToEnd, this.m_Hi, this.m_HiInclusive); }; DescendingSubSet.prototype.tailSet = function (fromElement, inclusive) { if (inclusive === undefined) { inclusive = true; } if (!this.inRange(fromElement, inclusive)) { throw new illegalargumentexception_1.IllegalArgumentException('fromElement out of range'); } return new DescendingSubSet(this.m_TreeSet, this.m_FromStart, this.m_Lo, this.m_LoInclusive, false, fromElement, inclusive); }; DescendingSubSet.prototype.descendingSet = function () { return new AscendingSubSet_1.AscendingSubSet(this.m_TreeSet, this.m_FromStart, this.m_Lo, this.m_LoInclusive, this.m_ToEnd, this.m_Hi, this.m_HiInclusive); }; DescendingSubSet.prototype.iterator = function () { return new DescendingSubSetIterator_1.DescendingSubSetIterator(this.m_TreeSet, this.absHighest(), this.absLowFence()); }; DescendingSubSet.prototype.descendingIterator = function () { return new DescendingSubSetIterator_1.DescendingSubSetIterator(this.m_TreeSet, this.absHighest(), this.absLowFence()); }; DescendingSubSet.prototype.subLowest = function () { return this.absHighest(); }; DescendingSubSet.prototype.subHighest = function () { return this.absLowest(); }; DescendingSubSet.prototype.subCeiling = function (e) { return this.absFloor(e); }; DescendingSubSet.prototype.subHigher = function (e) { return this.absLower(e); }; DescendingSubSet.prototype.subFloor = function (e) { return this.absCeiling(e); }; DescendingSubSet.prototype.subLower = function (e) { return this.absHigher(e); }; return DescendingSubSet; }(NavigableSubSet_1.NavigableSubSet)); exports.DescendingSubSet = DescendingSubSet;