AVLMapSubMap.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap = exports.AVLMapSubMap = void 0;
  4. const JavaMapEntry_1 = require("../../../java/util/JavaMapEntry");
  5. const AVLMapSubCollection_1 = require("../../../core/adt/map/AVLMapSubCollection");
  6. const AVLMapIntervall_1 = require("../../../core/adt/map/AVLMapIntervall");
  7. const AVLMapSubEntrySetIterator_1 = require("../../../core/adt/map/AVLMapSubEntrySetIterator");
  8. const AVLMapSubKeySet_1 = require("../../../core/adt/map/AVLMapSubKeySet");
  9. const AVLMap_1 = require("../../../core/adt/map/AVLMap");
  10. const AVLMapSubKeySetIterator_1 = require("../../../core/adt/map/AVLMapSubKeySetIterator");
  11. const JavaObject_1 = require("../../../java/lang/JavaObject");
  12. const AVLMapSubEntrySet_1 = require("../../../core/adt/map/AVLMapSubEntrySet");
  13. const JavaMap_1 = require("../../../java/util/JavaMap");
  14. const Vector_1 = require("../../../java/util/Vector");
  15. const AVLMapSubCollectionIterator_1 = require("../../../core/adt/map/AVLMapSubCollectionIterator");
  16. const IllegalArgumentException_1 = require("../../../java/lang/IllegalArgumentException");
  17. class AVLMapSubMap extends JavaObject_1.JavaObject {
  18. _par;
  19. _iv;
  20. _asc = false;
  21. /**
  22. * Erstellt eine neue Sub-Map relativ zur übergebenen {@link AVLMap}.
  23. *
  24. * @param parent Die {@link AVLMap} auf der diese Sup-Map operiert.
  25. * @param intervall Das {@link AVLMapIntervall} auf das sich diese Sub-Map bezieht.
  26. */
  27. constructor(parent, intervall, asc) {
  28. super();
  29. this._par = parent;
  30. this._iv = intervall;
  31. this._asc = asc;
  32. }
  33. toString() {
  34. let s = "";
  35. for (let e of this.entrySet())
  36. s += (s.length === 0 ? "" : ", ") + e;
  37. return "Entries = [" + s.valueOf() + "], iv = " + this._iv + ", asc = " + this._asc;
  38. }
  39. equals(o) {
  40. if (o === this)
  41. return true;
  42. if (((o instanceof JavaObject_1.JavaObject) && (o.isTranspiledInstanceOf('java.util.Map'))) === false)
  43. return false;
  44. let mapO = (0, JavaMap_1.cast_java_util_Map)(o);
  45. if (mapO.size() !== this.size())
  46. return false;
  47. for (let e of this.entrySet())
  48. if (JavaObject_1.JavaObject.equalsTranspiler(e.getValue(), (mapO.get(e.getKey()))) === false)
  49. return false;
  50. return true;
  51. }
  52. hashCode() {
  53. let h = 0;
  54. for (let entry of this.entrySet())
  55. h += JavaObject_1.JavaObject.getTranspilerHashCode(entry);
  56. return h;
  57. }
  58. comparator() {
  59. return this._par.bcGetComparator(this._iv);
  60. }
  61. firstKey() {
  62. return this._asc ? this._par.bcGetFirstKeyOrException(this._iv) : this._par.bcGetLastKeyOrException(this._iv);
  63. }
  64. lastKey() {
  65. return this._asc ? this._par.bcGetLastKeyOrException(this._iv) : this._par.bcGetFirstKeyOrException(this._iv);
  66. }
  67. keySet() {
  68. return new AVLMapSubKeySet_1.AVLMapSubKeySet(this);
  69. }
  70. values() {
  71. return new AVLMapSubCollection_1.AVLMapSubCollection(this);
  72. }
  73. entrySet() {
  74. return new AVLMapSubEntrySet_1.AVLMapSubEntrySet(this);
  75. }
  76. size() {
  77. return this._par.bcGetSize(this._iv);
  78. }
  79. isEmpty() {
  80. return this._par.bcIsEmpty(this._iv);
  81. }
  82. containsKey(key) {
  83. return this._par.bcContainsKey(key, this._iv);
  84. }
  85. containsValue(value) {
  86. return this._par.bcContainsValue(value, this._iv);
  87. }
  88. get(key) {
  89. return this._par.bcGetValueOfKeyOrNull(key, this._iv);
  90. }
  91. put(key, value) {
  92. return this._par.bcAddEntryReturnOldValueOrNull(key, value, this._iv);
  93. }
  94. remove(key) {
  95. return this._par.bcRemoveKeyReturnOldValueOrNull(key, this._iv);
  96. }
  97. putAll(map) {
  98. this._par.bcAddAllEntriesOfMap(map, this._iv);
  99. }
  100. clear() {
  101. let iter = this.bcGetSubEntrySetIterator();
  102. while (iter.hasNext()) {
  103. iter.next();
  104. iter.remove();
  105. }
  106. }
  107. lowerEntry(key) {
  108. return this._asc ? this._par.bcGetLowerEntryOrNull(key, this._iv) : this._par.bcGetHigherEntryOrNull(key, this._iv);
  109. }
  110. lowerKey(key) {
  111. return this._asc ? this._par.bcGetLowerKeyOrNull(key, this._iv) : this._par.bcGetHigherKeyOrNull(key, this._iv);
  112. }
  113. floorEntry(key) {
  114. return this._asc ? this._par.bcGetFloorEntryOrNull(key, this._iv) : this._par.bcGetCeilingEntryOrNull(key, this._iv);
  115. }
  116. floorKey(key) {
  117. return this._asc ? this._par.bcGetFloorKeyOrNull(key, this._iv) : this._par.bcGetCeilingKeyOrNull(key, this._iv);
  118. }
  119. ceilingEntry(key) {
  120. return this._asc ? this._par.bcGetCeilingEntryOrNull(key, this._iv) : this._par.bcGetFloorEntryOrNull(key, this._iv);
  121. }
  122. ceilingKey(key) {
  123. return this._asc ? this._par.bcGetCeilingKeyOrNull(key, this._iv) : this._par.bcGetFloorKeyOrNull(key, this._iv);
  124. }
  125. higherEntry(key) {
  126. return this._asc ? this._par.bcGetHigherEntryOrNull(key, this._iv) : this._par.bcGetLowerEntryOrNull(key, this._iv);
  127. }
  128. higherKey(key) {
  129. return this._asc ? this._par.bcGetHigherKeyOrNull(key, this._iv) : this._par.bcGetLowerKeyOrNull(key, this._iv);
  130. }
  131. firstEntry() {
  132. return this._asc ? this._par.bcGetFirstEntryOrNull(this._iv) : this._par.bcGetLastEntryOrNull(this._iv);
  133. }
  134. lastEntry() {
  135. return this._asc ? this._par.bcGetLastEntryOrNull(this._iv) : this._par.bcGetFirstEntryOrNull(this._iv);
  136. }
  137. pollFirstEntry() {
  138. return this._asc ? this._par.bcPollFirstEntryOrNull(this._iv) : this._par.bcPollLastEntryOrNull(this._iv);
  139. }
  140. pollLastEntry() {
  141. return this._asc ? this._par.bcPollLastEntryOrNull(this._iv) : this._par.bcPollFirstEntryOrNull(this._iv);
  142. }
  143. descendingMap() {
  144. return new AVLMapSubMap(this._par, this._iv, !this._asc);
  145. }
  146. navigableKeySet() {
  147. return new AVLMapSubKeySet_1.AVLMapSubKeySet(this);
  148. }
  149. descendingKeySet() {
  150. return new AVLMapSubKeySet_1.AVLMapSubKeySet(new AVLMapSubMap(this._par, this._iv, !this._asc));
  151. }
  152. /**
  153. * Implementation for method overloads of 'subMap'
  154. */
  155. subMap(__param0, __param1, __param2, __param3) {
  156. 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")) {
  157. let fromKey = __param0;
  158. let fromInclusive = __param1;
  159. let toKey = __param2;
  160. let toInclusive = __param3;
  161. return this._createMap(fromKey, fromInclusive, toKey, toInclusive, this._asc);
  162. }
  163. else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && (typeof __param1 !== "undefined")) && (typeof __param2 === "undefined") && (typeof __param3 === "undefined")) {
  164. let fromKey = __param0;
  165. let toKey = __param1;
  166. return this._createMap(fromKey, true, toKey, false, this._asc);
  167. }
  168. else
  169. throw new Error('invalid method overload');
  170. }
  171. /**
  172. * Implementation for method overloads of 'headMap'
  173. */
  174. headMap(__param0, __param1) {
  175. if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) {
  176. let toKey = __param0;
  177. let inclusive = __param1;
  178. return this._createMap(this._iv.from, this._iv.fromInc, toKey, inclusive, this._asc);
  179. }
  180. else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) {
  181. let toKey = __param0;
  182. return this._createMap(this._iv.from, this._iv.fromInc, toKey, false, this._asc);
  183. }
  184. else
  185. throw new Error('invalid method overload');
  186. }
  187. /**
  188. * Implementation for method overloads of 'tailMap'
  189. */
  190. tailMap(__param0, __param1) {
  191. if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) {
  192. let fromKey = __param0;
  193. let inclusive = __param1;
  194. return this._createMap(fromKey, inclusive, this._iv.to, this._iv.toInc, this._asc);
  195. }
  196. else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) {
  197. let fromKey = __param0;
  198. return this._createMap(fromKey, true, this._iv.to, this._iv.toInc, this._asc);
  199. }
  200. else
  201. throw new Error('invalid method overload');
  202. }
  203. bcAddKey(e) {
  204. return this._par.bcAddKey(e, this._iv);
  205. }
  206. bcAddAllEntries(c) {
  207. return this._par.bcAddAllEntries(c, this._iv);
  208. }
  209. bcAddEntryReturnBool(e) {
  210. return this._par.bcAddEntryReturnBool(e, this._iv);
  211. }
  212. bcContainsAllKeys(c) {
  213. return this._par.bcContainsAllKeys(c, this._iv);
  214. }
  215. bcContainsAllEntries(c) {
  216. return this._par.bcContainsAllEntries(c, this._iv);
  217. }
  218. bcContainsEntry(o) {
  219. return this._par.bcContainsEntry(o, this._iv);
  220. }
  221. bcRemoveKeyReturnBool(o) {
  222. return this._par.bcRemoveKeyReturnBool(o, this._iv);
  223. }
  224. bcRemoveEntry(o) {
  225. return this._par.bcRemoveEntry(o, this._iv);
  226. }
  227. bcRemoveAllKeys(c) {
  228. return this._par.bcRemoveAllKeys(c, this._iv);
  229. }
  230. bcRemoveAllEntries(c) {
  231. return this._par.bcRemoveAllEntries(c, this._iv);
  232. }
  233. bcRetainAllKeys(c) {
  234. let mapRetain = new AVLMap_1.AVLMap();
  235. for (let obj of c) {
  236. let key = obj;
  237. mapRetain.put(key, key);
  238. }
  239. let changed = false;
  240. let iterOfKeys = this.bcGetSubKeySetIterator();
  241. while (iterOfKeys.hasNext()) {
  242. let key = iterOfKeys.next();
  243. if (mapRetain.containsKey(key) === false) {
  244. iterOfKeys.remove();
  245. changed = true;
  246. }
  247. }
  248. return changed;
  249. }
  250. bcRetainAllEntries(c) {
  251. let mapSave = new AVLMap_1.AVLMap();
  252. let setSave = mapSave.entrySet();
  253. for (let o of c)
  254. if (this.bcContainsEntry(o))
  255. setSave.add((0, JavaMapEntry_1.cast_java_util_Map_Entry)(o));
  256. let changed = false;
  257. let iterOfEntries = this.bcGetSubEntrySetIterator();
  258. while (iterOfEntries.hasNext())
  259. if (setSave.contains(iterOfEntries.next()) === false) {
  260. iterOfEntries.remove();
  261. changed = true;
  262. }
  263. return changed;
  264. }
  265. firstEntryAsNode() {
  266. return this._asc ? this._par.bcGetFirstEntryOrNull(this._iv) : this._par.bcGetLastEntryOrNull(this._iv);
  267. }
  268. nextEntryOrNull(node) {
  269. return this._asc ? this._par.bcGetNextEntryOrNull(node, this._iv) : this._par.bcGetPrevEntryOrNull(node, this._iv);
  270. }
  271. bcAddAllKeys(c) {
  272. return this._par.bcAddAllKeys(c, this._iv);
  273. }
  274. bcGetLowerKeyOrNull(e) {
  275. return this._asc ? this._par.bcGetLowerKeyOrNull(e, this._iv) : this._par.bcGetHigherKeyOrNull(e, this._iv);
  276. }
  277. bcGetFloorKeyOrNull(e) {
  278. return this._asc ? this._par.bcGetFloorKeyOrNull(e, this._iv) : this._par.bcGetCeilingKeyOrNull(e, this._iv);
  279. }
  280. bcGetCeilingKeyOrNull(e) {
  281. return this._asc ? this._par.bcGetCeilingKeyOrNull(e, this._iv) : this._par.bcGetFloorKeyOrNull(e, this._iv);
  282. }
  283. bcGetHigherKeyOrNull(e) {
  284. return this._asc ? this._par.bcGetHigherKeyOrNull(e, this._iv) : this._par.bcGetLowerKeyOrNull(e, this._iv);
  285. }
  286. bcPollFirstKeyOrNull() {
  287. return this._asc ? this._par.bcPollFirstKeyOrNull(this._iv) : this._par.bcPollLastKeyOrNull(this._iv);
  288. }
  289. bcPollLastKeyOrNull() {
  290. return this._asc ? this._par.bcPollLastKeyOrNull(this._iv) : this._par.bcPollFirstKeyOrNull(this._iv);
  291. }
  292. bcGetArrayListOfKeys() {
  293. let v = new Vector_1.Vector();
  294. let iter = this.navigableKeySet().iterator();
  295. while (iter.hasNext())
  296. v.add(iter.next());
  297. return v;
  298. }
  299. bcGetArrayListOfValues() {
  300. let v = new Vector_1.Vector();
  301. let iter = this.values().iterator();
  302. while (iter.hasNext())
  303. v.add(iter.next());
  304. return v;
  305. }
  306. bcGetArrayListOfEntries() {
  307. let v = new Vector_1.Vector();
  308. let iter = this.entrySet().iterator();
  309. while (iter.hasNext())
  310. v.add(iter.next());
  311. return v;
  312. }
  313. bcGetSubKeySetIterator() {
  314. return new AVLMapSubKeySetIterator_1.AVLMapSubKeySetIterator(this);
  315. }
  316. bcGetSubKeySetDescending() {
  317. return new AVLMapSubKeySet_1.AVLMapSubKeySet(new AVLMapSubMap(this._par, this._iv, !this._asc));
  318. }
  319. bcGetSubKeySetDescendingIterator() {
  320. return new AVLMapSubKeySetIterator_1.AVLMapSubKeySetIterator(new AVLMapSubMap(this._par, this._iv, !this._asc));
  321. }
  322. /**
  323. * Implementation for method overloads of 'bcGetSubKeySet'
  324. */
  325. bcGetSubKeySet(__param0, __param1, __param2, __param3) {
  326. 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")) {
  327. let fromElement = __param0;
  328. let fromInclusive = __param1;
  329. let toElement = __param2;
  330. let toInclusive = __param3;
  331. return this._createSet(fromElement, fromInclusive, toElement, toInclusive, this._asc);
  332. }
  333. else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && (typeof __param1 !== "undefined")) && (typeof __param2 === "undefined") && (typeof __param3 === "undefined")) {
  334. let fromElement = __param0;
  335. let toElement = __param1;
  336. return this._createSet(fromElement, true, toElement, false, this._asc);
  337. }
  338. else
  339. throw new Error('invalid method overload');
  340. }
  341. /**
  342. * Implementation for method overloads of 'bcGetSubKeyHeadSet'
  343. */
  344. bcGetSubKeyHeadSet(__param0, __param1) {
  345. if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) {
  346. let toElement = __param0;
  347. let inclusive = __param1;
  348. return this._createSet(this._iv.from, this._iv.fromInc, toElement, inclusive, this._asc);
  349. }
  350. else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) {
  351. let toElement = __param0;
  352. return this._createSet(this._iv.from, this._iv.fromInc, toElement, false, this._asc);
  353. }
  354. else
  355. throw new Error('invalid method overload');
  356. }
  357. /**
  358. * Implementation for method overloads of 'bcGetSubKeyTailSet'
  359. */
  360. bcGetSubKeyTailSet(__param0, __param1) {
  361. if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) {
  362. let fromElement = __param0;
  363. let inclusive = __param1;
  364. return this._createSet(fromElement, inclusive, this._iv.to, this._iv.toInc, this._asc);
  365. }
  366. else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) {
  367. let fromElement = __param0;
  368. return this._createSet(fromElement, true, this._iv.to, this._iv.toInc, this._asc);
  369. }
  370. else
  371. throw new Error('invalid method overload');
  372. }
  373. bcGetSubCollectionIterator() {
  374. return new AVLMapSubCollectionIterator_1.AVLMapSubCollectionIterator(this);
  375. }
  376. bcContainsAllValues(c) {
  377. return this._par.bcContainsAllValues(c, this._iv);
  378. }
  379. bcGetSubEntrySetIterator() {
  380. return new AVLMapSubEntrySetIterator_1.AVLMapSubEntrySetIterator(this);
  381. }
  382. _createMap(from, fromInc, to, toInc, asc) {
  383. if (this._par.bcCheckOutOfIntervall(from, fromInc, this._iv))
  384. throw new IllegalArgumentException_1.IllegalArgumentException("FROM-KEY " + from + "/" + fromInc + " nicht in " + this._iv);
  385. if (this._par.bcCheckOutOfIntervall(to, toInc, this._iv))
  386. throw new IllegalArgumentException_1.IllegalArgumentException("TO-KEY " + to + "/" + toInc + " nicht in " + this._iv);
  387. return new AVLMapSubMap(this._par, new AVLMapIntervall_1.AVLMapIntervall(from, fromInc, to, toInc), asc);
  388. }
  389. _createSet(from, fromInc, to, toInc, asc) {
  390. return new AVLMapSubKeySet_1.AVLMapSubKeySet(this._createMap(from, fromInc, to, toInc, asc));
  391. }
  392. isTranspiledInstanceOf(name) {
  393. return ['java.util.Map', 'java.util.NavigableMap', 'de.nrw.schule.svws.core.adt.map.AVLMapSubMap', 'java.util.SortedMap'].includes(name);
  394. }
  395. }
  396. exports.AVLMapSubMap = AVLMapSubMap;
  397. function cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap(obj) {
  398. return obj;
  399. }
  400. exports.cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap = cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap;
  401. //# sourceMappingURL=AVLMapSubMap.js.map