"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap = exports.AVLMapSubMap = void 0; const JavaMapEntry_1 = require("../../../java/util/JavaMapEntry"); const AVLMapSubCollection_1 = require("../../../core/adt/map/AVLMapSubCollection"); const AVLMapIntervall_1 = require("../../../core/adt/map/AVLMapIntervall"); const AVLMapSubEntrySetIterator_1 = require("../../../core/adt/map/AVLMapSubEntrySetIterator"); const AVLMapSubKeySet_1 = require("../../../core/adt/map/AVLMapSubKeySet"); const AVLMap_1 = require("../../../core/adt/map/AVLMap"); const AVLMapSubKeySetIterator_1 = require("../../../core/adt/map/AVLMapSubKeySetIterator"); const JavaObject_1 = require("../../../java/lang/JavaObject"); const AVLMapSubEntrySet_1 = require("../../../core/adt/map/AVLMapSubEntrySet"); const JavaMap_1 = require("../../../java/util/JavaMap"); const Vector_1 = require("../../../java/util/Vector"); const AVLMapSubCollectionIterator_1 = require("../../../core/adt/map/AVLMapSubCollectionIterator"); const IllegalArgumentException_1 = require("../../../java/lang/IllegalArgumentException"); class AVLMapSubMap extends JavaObject_1.JavaObject { _par; _iv; _asc = false; /** * Erstellt eine neue Sub-Map relativ zur übergebenen {@link AVLMap}. * * @param parent Die {@link AVLMap} auf der diese Sup-Map operiert. * @param intervall Das {@link AVLMapIntervall} auf das sich diese Sub-Map bezieht. */ constructor(parent, intervall, asc) { super(); this._par = parent; this._iv = intervall; this._asc = asc; } toString() { let s = ""; for (let e of this.entrySet()) s += (s.length === 0 ? "" : ", ") + e; return "Entries = [" + s.valueOf() + "], iv = " + this._iv + ", asc = " + this._asc; } equals(o) { if (o === this) return true; if (((o instanceof JavaObject_1.JavaObject) && (o.isTranspiledInstanceOf('java.util.Map'))) === false) return false; let mapO = (0, JavaMap_1.cast_java_util_Map)(o); if (mapO.size() !== this.size()) return false; for (let e of this.entrySet()) if (JavaObject_1.JavaObject.equalsTranspiler(e.getValue(), (mapO.get(e.getKey()))) === false) return false; return true; } hashCode() { let h = 0; for (let entry of this.entrySet()) h += JavaObject_1.JavaObject.getTranspilerHashCode(entry); return h; } comparator() { return this._par.bcGetComparator(this._iv); } firstKey() { return this._asc ? this._par.bcGetFirstKeyOrException(this._iv) : this._par.bcGetLastKeyOrException(this._iv); } lastKey() { return this._asc ? this._par.bcGetLastKeyOrException(this._iv) : this._par.bcGetFirstKeyOrException(this._iv); } keySet() { return new AVLMapSubKeySet_1.AVLMapSubKeySet(this); } values() { return new AVLMapSubCollection_1.AVLMapSubCollection(this); } entrySet() { return new AVLMapSubEntrySet_1.AVLMapSubEntrySet(this); } size() { return this._par.bcGetSize(this._iv); } isEmpty() { return this._par.bcIsEmpty(this._iv); } containsKey(key) { return this._par.bcContainsKey(key, this._iv); } containsValue(value) { return this._par.bcContainsValue(value, this._iv); } get(key) { return this._par.bcGetValueOfKeyOrNull(key, this._iv); } put(key, value) { return this._par.bcAddEntryReturnOldValueOrNull(key, value, this._iv); } remove(key) { return this._par.bcRemoveKeyReturnOldValueOrNull(key, this._iv); } putAll(map) { this._par.bcAddAllEntriesOfMap(map, this._iv); } clear() { let iter = this.bcGetSubEntrySetIterator(); while (iter.hasNext()) { iter.next(); iter.remove(); } } lowerEntry(key) { return this._asc ? this._par.bcGetLowerEntryOrNull(key, this._iv) : this._par.bcGetHigherEntryOrNull(key, this._iv); } lowerKey(key) { return this._asc ? this._par.bcGetLowerKeyOrNull(key, this._iv) : this._par.bcGetHigherKeyOrNull(key, this._iv); } floorEntry(key) { return this._asc ? this._par.bcGetFloorEntryOrNull(key, this._iv) : this._par.bcGetCeilingEntryOrNull(key, this._iv); } floorKey(key) { return this._asc ? this._par.bcGetFloorKeyOrNull(key, this._iv) : this._par.bcGetCeilingKeyOrNull(key, this._iv); } ceilingEntry(key) { return this._asc ? this._par.bcGetCeilingEntryOrNull(key, this._iv) : this._par.bcGetFloorEntryOrNull(key, this._iv); } ceilingKey(key) { return this._asc ? this._par.bcGetCeilingKeyOrNull(key, this._iv) : this._par.bcGetFloorKeyOrNull(key, this._iv); } higherEntry(key) { return this._asc ? this._par.bcGetHigherEntryOrNull(key, this._iv) : this._par.bcGetLowerEntryOrNull(key, this._iv); } higherKey(key) { return this._asc ? this._par.bcGetHigherKeyOrNull(key, this._iv) : this._par.bcGetLowerKeyOrNull(key, this._iv); } firstEntry() { return this._asc ? this._par.bcGetFirstEntryOrNull(this._iv) : this._par.bcGetLastEntryOrNull(this._iv); } lastEntry() { return this._asc ? this._par.bcGetLastEntryOrNull(this._iv) : this._par.bcGetFirstEntryOrNull(this._iv); } pollFirstEntry() { return this._asc ? this._par.bcPollFirstEntryOrNull(this._iv) : this._par.bcPollLastEntryOrNull(this._iv); } pollLastEntry() { return this._asc ? this._par.bcPollLastEntryOrNull(this._iv) : this._par.bcPollFirstEntryOrNull(this._iv); } descendingMap() { return new AVLMapSubMap(this._par, this._iv, !this._asc); } navigableKeySet() { return new AVLMapSubKeySet_1.AVLMapSubKeySet(this); } descendingKeySet() { return new AVLMapSubKeySet_1.AVLMapSubKeySet(new AVLMapSubMap(this._par, this._iv, !this._asc)); } /** * Implementation for method overloads of 'subMap' */ subMap(__param0, __param1, __param2, __param3) { if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean") && ((typeof __param2 !== "undefined") && (typeof __param2 !== "undefined")) && ((typeof __param3 !== "undefined") && typeof __param3 === "boolean")) { let fromKey = __param0; let fromInclusive = __param1; let toKey = __param2; let toInclusive = __param3; return this._createMap(fromKey, fromInclusive, toKey, toInclusive, this._asc); } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && (typeof __param1 !== "undefined")) && (typeof __param2 === "undefined") && (typeof __param3 === "undefined")) { let fromKey = __param0; let toKey = __param1; return this._createMap(fromKey, true, toKey, false, this._asc); } else throw new Error('invalid method overload'); } /** * Implementation for method overloads of 'headMap' */ headMap(__param0, __param1) { if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) { let toKey = __param0; let inclusive = __param1; return this._createMap(this._iv.from, this._iv.fromInc, toKey, inclusive, this._asc); } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) { let toKey = __param0; return this._createMap(this._iv.from, this._iv.fromInc, toKey, false, this._asc); } else throw new Error('invalid method overload'); } /** * Implementation for method overloads of 'tailMap' */ tailMap(__param0, __param1) { if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) { let fromKey = __param0; let inclusive = __param1; return this._createMap(fromKey, inclusive, this._iv.to, this._iv.toInc, this._asc); } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) { let fromKey = __param0; return this._createMap(fromKey, true, this._iv.to, this._iv.toInc, this._asc); } else throw new Error('invalid method overload'); } bcAddKey(e) { return this._par.bcAddKey(e, this._iv); } bcAddAllEntries(c) { return this._par.bcAddAllEntries(c, this._iv); } bcAddEntryReturnBool(e) { return this._par.bcAddEntryReturnBool(e, this._iv); } bcContainsAllKeys(c) { return this._par.bcContainsAllKeys(c, this._iv); } bcContainsAllEntries(c) { return this._par.bcContainsAllEntries(c, this._iv); } bcContainsEntry(o) { return this._par.bcContainsEntry(o, this._iv); } bcRemoveKeyReturnBool(o) { return this._par.bcRemoveKeyReturnBool(o, this._iv); } bcRemoveEntry(o) { return this._par.bcRemoveEntry(o, this._iv); } bcRemoveAllKeys(c) { return this._par.bcRemoveAllKeys(c, this._iv); } bcRemoveAllEntries(c) { return this._par.bcRemoveAllEntries(c, this._iv); } bcRetainAllKeys(c) { let mapRetain = new AVLMap_1.AVLMap(); for (let obj of c) { let key = obj; mapRetain.put(key, key); } let changed = false; let iterOfKeys = this.bcGetSubKeySetIterator(); while (iterOfKeys.hasNext()) { let key = iterOfKeys.next(); if (mapRetain.containsKey(key) === false) { iterOfKeys.remove(); changed = true; } } return changed; } bcRetainAllEntries(c) { let mapSave = new AVLMap_1.AVLMap(); let setSave = mapSave.entrySet(); for (let o of c) if (this.bcContainsEntry(o)) setSave.add((0, JavaMapEntry_1.cast_java_util_Map_Entry)(o)); let changed = false; let iterOfEntries = this.bcGetSubEntrySetIterator(); while (iterOfEntries.hasNext()) if (setSave.contains(iterOfEntries.next()) === false) { iterOfEntries.remove(); changed = true; } return changed; } firstEntryAsNode() { return this._asc ? this._par.bcGetFirstEntryOrNull(this._iv) : this._par.bcGetLastEntryOrNull(this._iv); } nextEntryOrNull(node) { return this._asc ? this._par.bcGetNextEntryOrNull(node, this._iv) : this._par.bcGetPrevEntryOrNull(node, this._iv); } bcAddAllKeys(c) { return this._par.bcAddAllKeys(c, this._iv); } bcGetLowerKeyOrNull(e) { return this._asc ? this._par.bcGetLowerKeyOrNull(e, this._iv) : this._par.bcGetHigherKeyOrNull(e, this._iv); } bcGetFloorKeyOrNull(e) { return this._asc ? this._par.bcGetFloorKeyOrNull(e, this._iv) : this._par.bcGetCeilingKeyOrNull(e, this._iv); } bcGetCeilingKeyOrNull(e) { return this._asc ? this._par.bcGetCeilingKeyOrNull(e, this._iv) : this._par.bcGetFloorKeyOrNull(e, this._iv); } bcGetHigherKeyOrNull(e) { return this._asc ? this._par.bcGetHigherKeyOrNull(e, this._iv) : this._par.bcGetLowerKeyOrNull(e, this._iv); } bcPollFirstKeyOrNull() { return this._asc ? this._par.bcPollFirstKeyOrNull(this._iv) : this._par.bcPollLastKeyOrNull(this._iv); } bcPollLastKeyOrNull() { return this._asc ? this._par.bcPollLastKeyOrNull(this._iv) : this._par.bcPollFirstKeyOrNull(this._iv); } bcGetArrayListOfKeys() { let v = new Vector_1.Vector(); let iter = this.navigableKeySet().iterator(); while (iter.hasNext()) v.add(iter.next()); return v; } bcGetArrayListOfValues() { let v = new Vector_1.Vector(); let iter = this.values().iterator(); while (iter.hasNext()) v.add(iter.next()); return v; } bcGetArrayListOfEntries() { let v = new Vector_1.Vector(); let iter = this.entrySet().iterator(); while (iter.hasNext()) v.add(iter.next()); return v; } bcGetSubKeySetIterator() { return new AVLMapSubKeySetIterator_1.AVLMapSubKeySetIterator(this); } bcGetSubKeySetDescending() { return new AVLMapSubKeySet_1.AVLMapSubKeySet(new AVLMapSubMap(this._par, this._iv, !this._asc)); } bcGetSubKeySetDescendingIterator() { return new AVLMapSubKeySetIterator_1.AVLMapSubKeySetIterator(new AVLMapSubMap(this._par, this._iv, !this._asc)); } /** * Implementation for method overloads of 'bcGetSubKeySet' */ bcGetSubKeySet(__param0, __param1, __param2, __param3) { if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean") && ((typeof __param2 !== "undefined") && (typeof __param2 !== "undefined")) && ((typeof __param3 !== "undefined") && typeof __param3 === "boolean")) { let fromElement = __param0; let fromInclusive = __param1; let toElement = __param2; let toInclusive = __param3; return this._createSet(fromElement, fromInclusive, toElement, toInclusive, this._asc); } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && (typeof __param1 !== "undefined")) && (typeof __param2 === "undefined") && (typeof __param3 === "undefined")) { let fromElement = __param0; let toElement = __param1; return this._createSet(fromElement, true, toElement, false, this._asc); } else throw new Error('invalid method overload'); } /** * Implementation for method overloads of 'bcGetSubKeyHeadSet' */ bcGetSubKeyHeadSet(__param0, __param1) { if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) { let toElement = __param0; let inclusive = __param1; return this._createSet(this._iv.from, this._iv.fromInc, toElement, inclusive, this._asc); } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) { let toElement = __param0; return this._createSet(this._iv.from, this._iv.fromInc, toElement, false, this._asc); } else throw new Error('invalid method overload'); } /** * Implementation for method overloads of 'bcGetSubKeyTailSet' */ bcGetSubKeyTailSet(__param0, __param1) { if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) { let fromElement = __param0; let inclusive = __param1; return this._createSet(fromElement, inclusive, this._iv.to, this._iv.toInc, this._asc); } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) { let fromElement = __param0; return this._createSet(fromElement, true, this._iv.to, this._iv.toInc, this._asc); } else throw new Error('invalid method overload'); } bcGetSubCollectionIterator() { return new AVLMapSubCollectionIterator_1.AVLMapSubCollectionIterator(this); } bcContainsAllValues(c) { return this._par.bcContainsAllValues(c, this._iv); } bcGetSubEntrySetIterator() { return new AVLMapSubEntrySetIterator_1.AVLMapSubEntrySetIterator(this); } _createMap(from, fromInc, to, toInc, asc) { if (this._par.bcCheckOutOfIntervall(from, fromInc, this._iv)) throw new IllegalArgumentException_1.IllegalArgumentException("FROM-KEY " + from + "/" + fromInc + " nicht in " + this._iv); if (this._par.bcCheckOutOfIntervall(to, toInc, this._iv)) throw new IllegalArgumentException_1.IllegalArgumentException("TO-KEY " + to + "/" + toInc + " nicht in " + this._iv); return new AVLMapSubMap(this._par, new AVLMapIntervall_1.AVLMapIntervall(from, fromInc, to, toInc), asc); } _createSet(from, fromInc, to, toInc, asc) { return new AVLMapSubKeySet_1.AVLMapSubKeySet(this._createMap(from, fromInc, to, toInc, asc)); } isTranspiledInstanceOf(name) { return ['java.util.Map', 'java.util.NavigableMap', 'de.nrw.schule.svws.core.adt.map.AVLMapSubMap', 'java.util.SortedMap'].includes(name); } } exports.AVLMapSubMap = AVLMapSubMap; function cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap(obj) { return obj; } exports.cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap = cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap; //# sourceMappingURL=AVLMapSubMap.js.map