AVLMapSubKeySet.ts 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. import { NavigableSet, cast_java_util_NavigableSet } from '../../../java/util/NavigableSet';
  2. import { JavaIterator, cast_java_util_Iterator } from '../../../java/util/JavaIterator';
  3. import { Collection, cast_java_util_Collection } from '../../../java/util/Collection';
  4. import { JavaObject, cast_java_lang_Object } from '../../../java/lang/JavaObject';
  5. import { JavaString, cast_java_lang_String } from '../../../java/lang/JavaString';
  6. import { SortedSet, cast_java_util_SortedSet } from '../../../java/util/SortedSet';
  7. import { AVLMapSubMap, cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap } from '../../../core/adt/map/AVLMapSubMap';
  8. import { Comparator, cast_java_util_Comparator } from '../../../java/util/Comparator';
  9. export class AVLMapSubKeySet<K, V> extends JavaObject implements NavigableSet<K> {
  10. private readonly _sub : AVLMapSubMap<K, V>;
  11. /**
  12. * Erstellt eine neues Sub-Set auf die übergebene {@link AVLMap}.
  13. *
  14. * @param sub Die {@link AVLMap} auf der operiert wird.
  15. */
  16. constructor(sub : AVLMapSubMap<K, V>) {
  17. super();
  18. this._sub = sub;
  19. }
  20. public toString() : String {
  21. return this._sub.toString();
  22. }
  23. public comparator() : Comparator<Partial<K>> {
  24. return this._sub.comparator();
  25. }
  26. public first() : K {
  27. return this._sub.firstKey();
  28. }
  29. public last() : K {
  30. return this._sub.lastKey();
  31. }
  32. public size() : number {
  33. return this._sub.size();
  34. }
  35. public isEmpty() : boolean {
  36. return this._sub.isEmpty();
  37. }
  38. public contains(o : unknown) : boolean {
  39. return this._sub.containsKey(o);
  40. }
  41. public toArray() : Array<unknown>;
  42. public toArray<T>(a : Array<T>) : Array<T>;
  43. /**
  44. * Implementation for method overloads of 'toArray'
  45. */
  46. public toArray<T>(__param0? : Array<T>) : Array<T> | Array<unknown> {
  47. if ((typeof __param0 === "undefined")) {
  48. return this._sub.bcGetArrayListOfKeys().toArray();
  49. } else if (((typeof __param0 !== "undefined") && Array.isArray(__param0))) {
  50. let a : Array<T> = __param0;
  51. return this._sub.bcGetArrayListOfKeys().toArray(a);
  52. } else throw new Error('invalid method overload');
  53. }
  54. public add(e : K) : boolean {
  55. return this._sub.bcAddKey(e);
  56. }
  57. public remove(o : unknown) : boolean {
  58. return this._sub.bcRemoveKeyReturnBool(o);
  59. }
  60. public containsAll(c : Collection<unknown>) : boolean {
  61. return this._sub.bcContainsAllKeys(c);
  62. }
  63. public addAll(c : Collection<K>) : boolean {
  64. return this._sub.bcAddAllKeys(c);
  65. }
  66. public retainAll(c : Collection<unknown>) : boolean {
  67. return this._sub.bcRetainAllKeys(c);
  68. }
  69. public removeAll(c : Collection<unknown>) : boolean {
  70. return this._sub.bcRemoveAllKeys(c);
  71. }
  72. public clear() : void {
  73. this._sub.clear();
  74. }
  75. public lower(e : K) : K | null {
  76. return this._sub.bcGetLowerKeyOrNull(e);
  77. }
  78. public floor(e : K) : K | null {
  79. return this._sub.bcGetFloorKeyOrNull(e);
  80. }
  81. public ceiling(e : K) : K | null {
  82. return this._sub.bcGetCeilingKeyOrNull(e);
  83. }
  84. public higher(e : K) : K | null {
  85. return this._sub.bcGetHigherKeyOrNull(e);
  86. }
  87. public pollFirst() : K | null {
  88. return this._sub.bcPollFirstKeyOrNull();
  89. }
  90. public pollLast() : K | null {
  91. return this._sub.bcPollLastKeyOrNull();
  92. }
  93. public iterator() : JavaIterator<K> {
  94. return this._sub.bcGetSubKeySetIterator();
  95. }
  96. public descendingSet() : NavigableSet<K> {
  97. return this._sub.bcGetSubKeySetDescending();
  98. }
  99. public descendingIterator() : JavaIterator<K> {
  100. return this._sub.bcGetSubKeySetDescendingIterator();
  101. }
  102. public subSet(fromElement : K, fromInclusive : boolean, toElement : K, toInclusive : boolean) : NavigableSet<K>;
  103. public subSet(fromElement : K, toElement : K) : SortedSet<K>;
  104. /**
  105. * Implementation for method overloads of 'subSet'
  106. */
  107. public subSet(__param0 : K, __param1 : K | boolean, __param2? : K, __param3? : boolean) : NavigableSet<K> | SortedSet<K> {
  108. 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")) {
  109. let fromElement : K = __param0 as unknown as K;
  110. let fromInclusive : boolean = __param1 as boolean;
  111. let toElement : K = __param2 as unknown as K;
  112. let toInclusive : boolean = __param3 as boolean;
  113. return this._sub.bcGetSubKeySet(fromElement, fromInclusive, toElement, toInclusive);
  114. } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && (typeof __param1 !== "undefined")) && (typeof __param2 === "undefined") && (typeof __param3 === "undefined")) {
  115. let fromElement : K = __param0 as unknown as K;
  116. let toElement : K = __param1 as unknown as K;
  117. return this._sub.bcGetSubKeySet(fromElement, toElement);
  118. } else throw new Error('invalid method overload');
  119. }
  120. public headSet(toElement : K, inclusive : boolean) : NavigableSet<K>;
  121. public headSet(toElement : K) : SortedSet<K>;
  122. /**
  123. * Implementation for method overloads of 'headSet'
  124. */
  125. public headSet(__param0 : K, __param1? : boolean) : NavigableSet<K> | SortedSet<K> {
  126. if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) {
  127. let toElement : K = __param0 as unknown as K;
  128. let inclusive : boolean = __param1 as boolean;
  129. return this._sub.bcGetSubKeyHeadSet(toElement, inclusive);
  130. } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) {
  131. let toElement : K = __param0 as unknown as K;
  132. return this._sub.bcGetSubKeyHeadSet(toElement);
  133. } else throw new Error('invalid method overload');
  134. }
  135. public tailSet(fromElement : K, inclusive : boolean) : NavigableSet<K>;
  136. public tailSet(fromElement : K) : SortedSet<K>;
  137. /**
  138. * Implementation for method overloads of 'tailSet'
  139. */
  140. public tailSet(__param0 : K, __param1? : boolean) : NavigableSet<K> | SortedSet<K> {
  141. if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && ((typeof __param1 !== "undefined") && typeof __param1 === "boolean")) {
  142. let fromElement : K = __param0 as unknown as K;
  143. let inclusive : boolean = __param1 as boolean;
  144. return this._sub.bcGetSubKeyTailSet(fromElement, inclusive);
  145. } else if (((typeof __param0 !== "undefined") && (typeof __param0 !== "undefined")) && (typeof __param1 === "undefined")) {
  146. let fromElement : K = __param0 as unknown as K;
  147. return this._sub.bcGetSubKeyTailSet(fromElement);
  148. } else throw new Error('invalid method overload');
  149. }
  150. isTranspiledInstanceOf(name : string): boolean {
  151. return ['java.util.SortedSet', 'java.util.Collection', 'de.nrw.schule.svws.core.adt.map.AVLMapSubKeySet', 'java.util.Set', 'java.util.NavigableSet', 'java.lang.Iterable'].includes(name);
  152. }
  153. public [Symbol.iterator](): Iterator<K> {
  154. let iter : JavaIterator<K> = this.iterator();
  155. const result : Iterator<K> = {
  156. next() : IteratorResult<K> {
  157. if (iter.hasNext())
  158. return { value : iter.next(), done : false };
  159. return { value : null, done : true };
  160. }
  161. };
  162. return result;
  163. }
  164. }
  165. export function cast_de_nrw_schule_svws_core_adt_map_AVLMapSubKeySet<K, V>(obj : unknown) : AVLMapSubKeySet<K, V> {
  166. return obj as AVLMapSubKeySet<K, V>;
  167. }