Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

您好作者,对算法的某处有个疑问 #6

Open
moushicheng opened this issue Feb 13, 2024 · 3 comments
Open

您好作者,对算法的某处有个疑问 #6

moushicheng opened this issue Feb 13, 2024 · 3 comments

Comments

@moushicheng
Copy link

moushicheng commented Feb 13, 2024

位置

    let origin = this.findItemById(item.origin);
    for (let i = destIndex; ; i++) {
      if (!scanning) {
        destIndex = i;
      }
      if (i === this.content.length) {
        break;
      }

      const o = this.content[i];
      // 疑惑: oorigin和origin会出现不同的情况吗?都是this.findItemById(item.origin);
      const oorigin = this.findItemById(item.origin);
      // Insert i before o
      // case1: or < ir < i < o => break
      // case2: or = ir < min(i, o) < max(i, o) => break
      if (oorigin < origin || (oorigin === origin && item.id[0] <= o.id[0])) {
        break;
      }

疑问写在注释内部了,我感觉正确的算法是不是应该是
const oorigin = this.finditemByid(o)?

@pedrogao
Copy link
Owner

pedrogao commented Feb 15, 2024 via email

@moushicheng
Copy link
Author

请问是怎么变化的呢?没有看到任何对item或者item.origin的赋值语句

@pedrogao
Copy link
Owner

不好意思,我会错你的意思了,item 的内容不会变,但它的 origin及originRight会在merge的时候变,因此每次取origin都需要调用一次函数

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants