AVLMapNode.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { JavaMapEntry, cast_java_util_Map_Entry } from '../../../java/util/JavaMapEntry';
  2. import { JavaObject, cast_java_lang_Object } from '../../../java/lang/JavaObject';
  3. import { JavaString, cast_java_lang_String } from '../../../java/lang/JavaString';
  4. import { UnsupportedOperationException, cast_java_lang_UnsupportedOperationException } from '../../../java/lang/UnsupportedOperationException';
  5. export class AVLMapNode<K, V> extends JavaObject implements JavaMapEntry<K, V> {
  6. readonly _key : K;
  7. _val : V;
  8. _prev : AVLMapNode<K, V> | null = null;
  9. _next : AVLMapNode<K, V> | null = null;
  10. _childL : AVLMapNode<K, V> | null = null;
  11. _childR : AVLMapNode<K, V> | null = null;
  12. _height : number = 1;
  13. _size : number = 1;
  14. /**
  15. * Erstellt ein neues Blatt des Baumes.
  16. */
  17. constructor(key : K, val : V) {
  18. super();
  19. this._key = key;
  20. this._val = val;
  21. }
  22. public toString() : String {
  23. return "[" + this._key + ", " + this._val + "]";
  24. }
  25. public equals(o : unknown) : boolean {
  26. if (((o instanceof JavaObject) && (o.isTranspiledInstanceOf('java.util.Map.Entry'))) === false)
  27. return false;
  28. let e : JavaMapEntry<unknown, unknown> | null = cast_java_util_Map_Entry(o);
  29. return JavaObject.equalsTranspiler(this._key, (e.getKey())) && (JavaObject.equalsTranspiler(this._val, (e.getValue())));
  30. }
  31. public hashCode() : number {
  32. return JavaObject.getTranspilerHashCode(this._key) ^ JavaObject.getTranspilerHashCode(this._val);
  33. }
  34. public getKey() : K {
  35. return this._key;
  36. }
  37. public getValue() : V {
  38. return this._val;
  39. }
  40. public setValue(value : V) : V {
  41. throw new UnsupportedOperationException()
  42. }
  43. isTranspiledInstanceOf(name : string): boolean {
  44. return ['de.nrw.schule.svws.core.adt.map.AVLMapNode', 'java.util.Map.Entry'].includes(name);
  45. }
  46. }
  47. export function cast_de_nrw_schule_svws_core_adt_map_AVLMapNode<K, V>(obj : unknown) : AVLMapNode<K, V> {
  48. return obj as AVLMapNode<K, V>;
  49. }