AVLMapSubEntrySetIterator.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { JavaObject, cast_java_lang_Object } from '../../../java/lang/JavaObject';
  2. import { IllegalStateException, cast_java_lang_IllegalStateException } from '../../../java/lang/IllegalStateException';
  3. import { JavaMapEntry, cast_java_util_Map_Entry } from '../../../java/util/JavaMapEntry';
  4. import { JavaIterator, cast_java_util_Iterator } from '../../../java/util/JavaIterator';
  5. import { NoSuchElementException, cast_java_util_NoSuchElementException } from '../../../java/util/NoSuchElementException';
  6. import { AVLMapSubMap, cast_de_nrw_schule_svws_core_adt_map_AVLMapSubMap } from '../../../core/adt/map/AVLMapSubMap';
  7. export class AVLMapSubEntrySetIterator<K, V> extends JavaObject implements JavaIterator<JavaMapEntry<K, V>> {
  8. private readonly _sub : AVLMapSubMap<K, V>;
  9. private _current : JavaMapEntry<K, V> | null = null;
  10. private _next : JavaMapEntry<K, V> | null = null;
  11. /**
  12. * Erstellt einen neuen ENTRY-Iterator für die angegebene {@link AVLMapSubMap} im gültigen
  13. * {@link AVLMapIntervall}.
  14. *
  15. * @param sub Die {@link AVLMapSubMap} auf der operiert wird.
  16. */
  17. constructor(sub : AVLMapSubMap<K, V>) {
  18. super();
  19. this._sub = sub;
  20. this._current = null;
  21. this._next = this._sub.firstEntry();
  22. }
  23. public next() : JavaMapEntry<K, V> {
  24. if (this._next === null)
  25. throw new NoSuchElementException()
  26. this._current = this._next;
  27. this._next = this._sub.higherEntry(this._next.getKey());
  28. return this._current;
  29. }
  30. public hasNext() : boolean {
  31. return this._next !== null;
  32. }
  33. public remove() : void {
  34. if (this._current === null)
  35. throw new IllegalStateException()
  36. this._sub.remove(this._current.getKey());
  37. this._current = null;
  38. }
  39. isTranspiledInstanceOf(name : string): boolean {
  40. return ['java.util.Iterator', 'de.nrw.schule.svws.core.adt.map.AVLMapSubEntrySetIterator'].includes(name);
  41. }
  42. }
  43. export function cast_de_nrw_schule_svws_core_adt_map_AVLMapSubEntrySetIterator<K, V>(obj : unknown) : AVLMapSubEntrySetIterator<K, V> {
  44. return obj as AVLMapSubEntrySetIterator<K, V>;
  45. }