shared/trie.js
// Apply entries to another tree, return leaves
Apply entries to another tree, return leaves
Apply entries to another tree return leaves
applyTo(ano) {
    const outer = this;
    const ns = new Set(function* nsgen() {
      yield* ano.entries;
      yield* outer.entries;
    }());
    ano.entries = ns;
    let leaves = [];
    for(let i = 0; i < 26; ++i)
      if(this.children[i])
        if(!ano.children[i]) {
          const [node, subleaves] = this.children[i].deepCopy();
          ano.children[i] = node;
          leaves = leaves.concat(subleaves);
        } else leaves = leaves.concat(this.children[i].applyTo(ano.children[i]));
    if(leaves.length === 0) leaves = [ano];
    return leaves;
  }
applyTo ( ano ) { const outer = this ; const ns = new Set ( function * nsgen ( ) { yield * ano . entries ; yield * outer . entries ; } ( ) ) ; ano . entries = ns ; let leaves = [ ] ; for ( let i = 0 ; i < 26 ; ++ i ) if ( this . children [ i ] ) if ( ! ano . children [ i ] ) { const [ node , subleaves ] = this . children [ i ] . deepCopy ( ) ; ano . children [ i ] = node ; leaves = leaves . concat ( subleaves ) ; } else leaves = leaves . concat ( this . children [ i ] . applyTo ( ano . children [ i ] ) ) ; if ( leaves . length === 0 ) leaves = [ ano ] ; return leaves ; }
Apply entries to another tree, return leaves
Apply entries to another tree return leaves