简体   繁体   English

是否有名称删除双向链表边缘的一半?

[英]Is there a name for removing half of a doubly linked list edge?

Note: This isn't specific to Java/C/C++, but linked lists being as common as they are, I opted to tag it under those languages as well as doubly-linked-lists. 注意:这不是特定于Java / C / C ++,但是链表很常见,因此我选择在这些语言以及双向链表下标记它。 If that's wrong, I can change it! 如果那是错误的,我可以更改它!

Let's say you have a standard doubly link list implementation: 假设您有一个标准的双链表实现:

struct List {
    int Number;
    struct List *blink;
    struct List *flink;
};

and that you have the following list: 并且您具有以下列表:

1 <--> 2 <--> 3 <--> 4 <--> 5

Now, in my case, I've been using the flink as a terminator of sorts, and unlinking nodes in a single direction: 现在,就我而言,我一直在使用flink作为各种终止符,并在单个方向上取消链接节点:

1 <--> 2 <--> 3 <--| 4 <--> 5

So 3's flink is null , but 4's blink points to 3. 因此3的flinknull ,但4的blink指向3。

(Mildly unrelated, I've been doing this to allow for quick modification and restoration of linked lists, and have things like: (有一点无关,我一直在这样做,以便快速修改和恢复链接列表,并具有以下内容:

1 <--> 2 <--| 3 <--> 4 <--> 5
         <--> 6 <--| 7 <--> 8
                <--> 9 <--> 10 <--> 11

to build a list of 1 2 6 9 10 11 ) 建立一个1 2 6 9 10 11的列表)

My question is really just "does this type of operation have a well defined name?" 我的问题确实只是“这种类型的操作名称是否明确?” I've been calling it "shearing", but if there's a real name that'd be nice to know. 我一直称其为“剪切”,但是如果有真实姓名,我很高兴知道。

It is a kind of messy thing with doubly linked list. 双链表是一种杂乱的事情。 It is basically deleting nodes in an improper way. 它基本上是以不适当的方式删除节点。

Why I am saying it improper is, consider nodes 2 & 6, 2's flink is null and 6's blink points to 2. 为什么我说这是不正确的,请考虑节​​点2和flinkflink为空,6的blink指向2。

By this you are telling 2 is the last node and 2 is in the back of 6. This is contradiction. 这样,您就知道2是最后一个节点,2在6的后面。这是矛盾的。

Where do you need this kind of approach? 您在哪里需要这种方法?

Well, unless you're also saving the pointers to the nodes 3, 4, 5, 7, and 8 then this would be called a "memory leak". 好吧,除非您还保存指向节点3、4、5、7和8的指针,否则这将被称为“内存泄漏”。

ie allocated memory you no longer have a way of accessing and therefore freeing. 也就是说,分配的内存不再具有访问和释放的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM