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.

116 lines (115 loc) 4.3 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 abstractset_1 = require("../abstractset"); var treemap_1 = require("../treemap"); var NavigableSubMap_1 = require("./NavigableSubMap"); var TreeMapKeySet = /** @class */ (function (_super) { __extends(TreeMapKeySet, _super); function TreeMapKeySet(map) { var _this = _super.call(this) || this; _this.map = map; return _this; } TreeMapKeySet.prototype.iterator = function () { if (this.map instanceof treemap_1.TreeMap) { return this.map.keyIterator(); } else if (this.map instanceof NavigableSubMap_1.NavigableSubMap) { return this.map.keyIterator(); } return null; }; TreeMapKeySet.prototype.descendingIterator = function () { if (this.map instanceof treemap_1.TreeMap) { return this.map.descendingKeyIterator(); } else if (this.map instanceof NavigableSubMap_1.NavigableSubMap) { return this.map.descendingKeyIterator(); } return null; }; TreeMapKeySet.prototype.size = function () { return this.map.size(); }; TreeMapKeySet.prototype.isEmpty = function () { return this.map.isEmpty(); }; TreeMapKeySet.prototype.contains = function (key) { return this.map.containsKey(key); }; TreeMapKeySet.prototype.clear = function () { this.map.clear(); }; TreeMapKeySet.prototype.lower = function (key) { return this.map.lowerKey(key); }; TreeMapKeySet.prototype.floor = function (key) { return this.map.floorKey(key); }; TreeMapKeySet.prototype.ceiling = function (key) { return this.map.ceilingKey(key); }; TreeMapKeySet.prototype.higher = function (key) { return this.map.higherKey(key); }; TreeMapKeySet.prototype.first = function () { return this.map.firstKey(); }; TreeMapKeySet.prototype.last = function () { return this.map.lastKey(); }; TreeMapKeySet.prototype.comparator = function () { return this.map.comparator(); }; TreeMapKeySet.prototype.pollFirst = function () { var e = this.map.pollFirstEntry(); return e === null ? null : e.getKey(); }; TreeMapKeySet.prototype.pollLast = function () { var e = this.map.pollLastEntry(); return e === null ? null : e.getKey(); }; TreeMapKeySet.prototype.remove = function (key) { var oldSize = this.size(); this.map.remove(key); return this.size() !== oldSize; }; TreeMapKeySet.prototype.subSet = function (fromElement, toElementOrfromInclusive, toEle, toIncl) { if (typeof toElementOrfromInclusive === 'boolean') { return new TreeMapKeySet(this.map.subMap(fromElement, toElementOrfromInclusive, toEle, toIncl)); } else { return new TreeMapKeySet(this.map.subMap(fromElement, true, toEle, false)); } }; TreeMapKeySet.prototype.headSet = function (toElement, inclusive) { if (inclusive === undefined) { inclusive = false; } return new TreeMapKeySet(this.map.headMap(toElement, inclusive)); }; TreeMapKeySet.prototype.tailSet = function (fromElement, inclusive) { if (inclusive === undefined) { inclusive = false; } return new TreeMapKeySet(this.map.tailMap(fromElement, inclusive)); }; TreeMapKeySet.prototype.descendingSet = function () { return new TreeMapKeySet(this.map.descendingMap()); }; return TreeMapKeySet; }(abstractset_1.AbstractSet)); exports.TreeMapKeySet = TreeMapKeySet;