SplayTree.js
/**
   * Search for the entry
   * if it found splays the tree base on it and then remove it
   * if not, last accessed node will be root
   * @param {number} key - The key of entry to be removed
   */
Search for the entry
if it found splays the tree base on it and then remove it
if not, last accessed node will be root
@param {number} key - The key of entry to be removed
Search for the entry if it found splays the tree base on it and then remove it if not last accessed node will be root @param { number } key - The key of entry to be removed
delete(key) {
    const result = this.search(key);
    if (!result) return false;
    let r = this._root;
    if (!r.left && !r.right) {
      this._root = null;
    } else if (!r.left) {
      this._root = this._root.right;
      this._root.parent = null;
    } else if (!r.right) {
      this._root = this._root.left;
      this._root.parent = null;
    } else {
      const leftMax = this.maxNode(r.left);
      this.splay(leftMax);
      this._root.right = this._root.right.right;
      this._root.right.parent = this._root
    }
    this._size--;
  }
delete ( key ) { const result = this . search ( key ) ; if ( ! result ) return false ; let r = this . _root ; if ( ! r . left && ! r . right ) { this . _root = null ; } else if ( ! r . left ) { this . _root = this . _root . right ; this . _root . parent = null ; } else if ( ! r . right ) { this . _root = this . _root . left ; this . _root . parent = null ; } else { const leftMax = this . maxNode ( r . left ) ; this . splay ( leftMax ) ; this . _root . right = this . _root . right . right ; this . _root . right . parent = this . _root } this . _size -- ; }
Search for the entry
 if it found splays the tree base on it and then remove it
 if not, last accessed node will be root
 @param {number} key - The key of entry to be removed
Search for the entry if it found splays the tree base on it and then remove it if not last accessed node will be root @param { number } key - The key of entry to be removed