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

Node的insert函数是不是错了 #62

Open
frsama opened this issue Jul 15, 2022 · 4 comments
Open

Node的insert函数是不是错了 #62

frsama opened this issue Jul 15, 2022 · 4 comments

Comments

@frsama
Copy link

frsama commented Jul 15, 2022

void insert(int val) {
    auto node = std::make_shared<Node>(val);
    node->next = next;
    node->prev = prev;
    if (prev)
        prev->next = node;
    if (next)
        next->prev = node;
}

在this节点处插入一个节点node(val),this的前驱改了,后继改了;
然而this节点没有做任何处理,消失在了虚空之中,或者说永远的留在了虚空之中。

还是说把它改正确也是作业的一部分,但是作业完全没提。
不过我看了一下,这个函数完全没用上。
image

@nwpuCfy
Copy link

nwpuCfy commented Sep 10, 2022

我也完全没用到这个函数

@xiaoleitongxue
Copy link

我也觉得这里有问题,看了半天没有看明白这个插入节点的操作步骤。

@huanGninGshuanG
Copy link

应该是有问题的,直接把当前节点替换了

@LLong0218
Copy link

我也是觉得,不仅是替换了当前数据,还没把this删干净

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

5 participants