list-diff icon indicating copy to clipboard operation
list-diff copied to clipboard

算法实现有bug

Open abell123456 opened this issue 8 years ago • 5 comments

如果新的列表项是:var newList = [{id: "c"}, {id: "e"}, {id: "a"}, {id: "b"}, {id: "f"}]
此时实现出来的结果就有问题。可以试下

abell123456 avatar Jun 07 '16 09:06 abell123456

@abell123456 同样感觉有这个bug,是不是因为遍历完newList,没有去除oldList中多余的部分啊,感觉在后面应该在添加几行代码来去除oldList多余的部分。

        var len = simulateList.length - 1 - j, k = 0;
        while (k <= len) {
            remove(i);
            k++;
        }

十分感谢大神分享 @livoras

zp1996 avatar Jun 19 '16 15:06 zp1996

@zp1996 +1

这里的 j 游标可能一直停留在某个 index 下,导致没有 remove simulateItem 游标 j 后面的 item

image

我是从 https://github.com/livoras/blog/issues/13 这篇文章跳过来的,这个错误是不影响的。

liuqipeng417 avatar Feb 24 '17 08:02 liuqipeng417

有兴趣的同学们可以发 PR

livoras avatar Feb 24 '17 15:02 livoras

自己用笔debug了一下,同感觉这里有点问题

LoveMandy avatar Mar 15 '17 10:03 LoveMandy

恩前面那个哥们PR了

YuxiangQue avatar Jun 12 '17 13:06 YuxiangQue