index.d.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import type TreeIterator from './TreeIterator';
  2. import { Container } from "../../ContainerBase";
  3. declare abstract class TreeContainer<K, V> extends Container<K | [K, V]> {
  4. /**
  5. * @param cmp The compare function.
  6. * @param enableIndex Whether to enable iterator indexing function.
  7. */
  8. protected constructor(cmp?: (x: K, y: K) => number, enableIndex?: boolean);
  9. /**
  10. * @param _key The given _key you want to compare.
  11. * @return An iterator to the first element not less than the given _key.
  12. */
  13. abstract lowerBound(_key: K): TreeIterator<K, V>;
  14. /**
  15. * @param _key The given _key you want to compare.
  16. * @return An iterator to the first element greater than the given _key.
  17. */
  18. abstract upperBound(_key: K): TreeIterator<K, V>;
  19. /**
  20. * @param _key The given _key you want to compare.
  21. * @return An iterator to the first element not greater than the given _key.
  22. */
  23. abstract reverseLowerBound(_key: K): TreeIterator<K, V>;
  24. /**
  25. * @param _key The given _key you want to compare.
  26. * @return An iterator to the first element less than the given _key.
  27. */
  28. abstract reverseUpperBound(_key: K): TreeIterator<K, V>;
  29. /**
  30. * @description Union the other tree to self.
  31. * @param other The other tree container you want to merge.
  32. */
  33. abstract union(other: TreeContainer<K, V>): void;
  34. clear(): void;
  35. /**
  36. * @description Update node's _key by iterator.
  37. * @param iter The iterator you want to change.
  38. * @param _key The _key you want to update.
  39. * @return Boolean about if the modification is successful.
  40. */
  41. updateKeyByIterator(iter: TreeIterator<K, V>, _key: K): boolean;
  42. eraseElementByPos(pos: number): void;
  43. /**
  44. * @description Remove the element of the specified _key.
  45. * @param _key The _key you want to remove.
  46. */
  47. eraseElementByKey(_key: K): void;
  48. eraseElementByIterator(iter: TreeIterator<K, V>): TreeIterator<K, V>;
  49. /**
  50. * @description Get the height of the tree.
  51. * @return Number about the height of the RB-tree.
  52. */
  53. getHeight(): number;
  54. }
  55. export default TreeContainer;