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.
71 lines (70 loc) • 2.82 kB
JavaScript
"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 nullpointerexception_1 = require("../../lang/nullpointerexception");
var objects_1 = require("../objects");
var NavigableSubMapEntrySet = /** @class */ (function (_super) {
__extends(NavigableSubMapEntrySet, _super);
function NavigableSubMapEntrySet(nsubMap) {
var _this = _super.call(this) || this;
_this.nsubMap = nsubMap;
_this.m_Size = -1;
return _this;
}
NavigableSubMapEntrySet.prototype.size = function () {
if (this.nsubMap.fromStart && this.nsubMap.toEnd) {
return this.nsubMap.size();
}
if (this.m_Size === -1 || this.expectedModCount !== this.nsubMap.modCount) {
this.expectedModCount = this.nsubMap.modCount;
this.m_Size = 0;
var i = this.iterator();
while (i.hasNext()) {
this.m_Size++;
}
}
return this.m_Size;
};
NavigableSubMapEntrySet.prototype.isEmpty = function () {
var e = this.nsubMap.absLowest();
return e !== null || this.nsubMap.tooHigh(e.getKey());
};
NavigableSubMapEntrySet.prototype.contains = function (entry) {
if (entry === null) {
throw new nullpointerexception_1.NullPointerException();
}
var key = entry.getKey();
var value = this.nsubMap.get(key);
if (value !== null && objects_1.Objects.equals(value, entry.getValue())) {
return true;
}
return false;
};
NavigableSubMapEntrySet.prototype.remove = function (entry) {
if (entry === null) {
throw new nullpointerexception_1.NullPointerException();
}
var key = entry.getKey();
var valueInMap = this.nsubMap.get(key);
if (!objects_1.Objects.equals(valueInMap, entry.getValue())) {
return false;
}
var value = this.nsubMap.remove(key);
return value !== null && objects_1.Objects.equals(value, entry.getValue());
};
return NavigableSubMapEntrySet;
}(abstractset_1.AbstractSet));
exports.NavigableSubMapEntrySet = NavigableSubMapEntrySet;