链表的实际例子是什么?
我理解链表的定义,但它如何表示并与常见概念或项目相关?
例如,OOP 中的组合(编辑:最初说“继承”)可以与汽车相关。 现实生活中所有(大多数)汽车本质上都是一样的; 汽车有一个引擎,你可以start()它,你可以让汽车走()、stop()等等。 汽车通常具有最大载客量,但公共汽车和跑车之间的最大载客量有所不同,两者都是汽车。
是否有一些现实生活中直观的简单单链表示例,就像我们在继承中所看到的那样? 典型的教科书“链表”示例显示了一个带有整数的节点和指向下一个的指针,但它似乎不太有用。
感谢您的意见。
I understand the definition of a Linked List, but how can it be represented and related to a common concept or item?
For example, composition (EDIT: originally said 'inheritance') in OOP can be related to automobiles. All (most) automobiles in real life are the essentially same thing; an automobile has an Engine, you can start() it, you can make the car go(), stop() and so on. An automobile would typically have a maximum passenger capacity but it would differ between a Bus and a SportsCar, which are both automobiles.
Is there some real life, intuitive example of the plain ole' singly Linked List like we have with inheritance? The typical textbook Linked List example shows a node with an integer and a pointer to the next, and it just doesn't seem very useful.
Your input is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(30)
给出行进方向:方向中的每一步都是一个节点,每个节点之间的行进指令作为链接。
示例:
节点 1:从家里开始
链接:向南步行 3 个街区到鲍勃的房子
节点 2:鲍勃的房子
链接:向北步行 2 个街区到爱丽丝的房子。
节点 3:爱丽丝的房子
如果你想从一个地方到达另一个地方,你必须遵循每个中间位置(节点)的链接(说明),你不能直接从家跳到爱丽丝的家。
Giving travel directions: With each step in the directions being a node, and the travel instruction between each node as your link.
Example:
Node 1: Start at Home
Link: Walk 3 blocks South to Bob's House
Node 2: Bob's house
Link: Walk 2 blocks North to Alice's House.
Node 3: Alice's house
If you want to get one place to another you have to follow the links(instructions) from each intermediate place(node), you can't just skip from home to Alice's.
看一个链表:
[A]=> [B]=> [C]=> [D] =>
这是一列……火车! 每节车厢都包含一些东西,并连接到另一节车厢(或者最后一节车厢什么也没有)。 您只能在末尾添加一节车厢,如果您想删除一节车厢,则必须将前一节车厢与下一节车厢相连。
Look at a linked list :
[A]=> [B]=> [C]=> [D]=>
It's a ... Train ! Each railroad car contain something and is attached to another railroad car (or nothing for the last one). You can only add a railroad car at the end and if you want to get rid of one you must attach the previous one with the next one.
电话链直接作为链表实现。 其工作原理如下:
群组组织者收集所有成员的电话号码。
组织者为每个成员分配一个要呼叫的其他成员的号码。 (有时他们会分配自己的号码,以便知道消息已通过,但这是可选的。)
当需要发送消息时,组织者会呼叫列表的负责人并传递消息。
负责人呼叫分配给他们的号码并传递消息。
重复步骤 4,直到每个人都听到该消息。
显然,在步骤 2 中设置列表时必须小心,以便每个人都链接起来。 此外,该列表通常是公开的,因此如果有人听到答录机或忙音,他们可以拨打下一个号码并保持链条运转。
A telephone chain is implemented directly as a linked list. Here's how it works:
A group organizer collects the phone numbers of all members.
The organizer assigns each member the number of one other member to call. (Sometimes they will assign their own number so that they know the message got through, but this is optional.)
When a message needs to be sent, the organizer calls the head of the list and delivers the message.
The head calls the number they were assigned and delivers the message.
Step 4 is repeated until everyone has heard the message.
Obviously care must be taken to set up the list in step 2 so that everyone is linked. Also, the list is usually public so that if someone gets an answering machine or busy tone, they can call the next number down and keep the chain moving.
链表与一叠纸非常相似,每张纸上都有一个项目。 (与像钉板的数组相反。)它通常用于解决具有以下特征的问题:
重新排列普通数组是一种痛苦,在中间某处添加元素同时确保数组有足够的内存等是一种痛苦。 使用链表这些操作很简单。 假设您想将项目 #10 移动到项目 #2 和项目 #3 之间。 有了文件,你就可以把它捡起来并移动它。 对于数组,您必须将项目 3 到 9 移到一个槽上,然后将其放入。对于链表,您可以执行以下操作:告诉 9 后面的一项是 11,告诉 2 后面的一项是 10,告诉 10 后面的那个是 3。
我现在正在使用其中的几个,因为添加项目非常容易,并且以编程方式说“对列表中的每个项目执行此操作”。 其中之一是条目列表,就像电子表格中的一样。 另一个,我通过浏览第一个列表并添加对具有特定值的每个项目的引用来创建,以便我可以对它们进行批量操作。 能够从中间提取项目,或将它们添加到中间,而不必担心数组长度。 根据我的经验,这些是主要优势。
A linked list is very similar to a stack of papers, each with one item on it. (As opposed to arrays, which are like pegboards.) It's generally used to solve a problem with these characteristics:
Rearranging a plain array is a pain, adding an element somewhere in the middle while making sure the array has enough memory etc. is a pain. With linked list these operations are simple. Say you wanted to move item #10 to be between item #2 and item #3. With papers, you could just pick it up and move it. With an array, you would have to move items 3 through 9 over a slot, then put it in. With a linked list, you do this: Tell 9 that the one after it is 11, tell 2 the one after it is 10, tell 10 the one after it is 3.
I am using several of them right now, because of how easy it is to add items, and to programmatically say "do this action to every item in the list". One of them is a list of entries, like in a spreadsheet. The other, I make by going through that first list and adding a reference to every item that has a particular value, so that I can do batch operations on them. Being able to pluck items from the middle, or add them to the middle, and not having to worry about array length. Those are the main advantages in my experience.
在操作系统中...可以使用链表来跟踪哪些进程正在运行以及哪些进程正在睡眠...正在运行并想要睡眠的进程...从跟踪运行的 LinkedList 中删除进程,一旦睡眠时间结束,将其添加回活动进程 LinkedList
也许较新的操作系统正在使用一些时髦的数据结构......可以在那里使用链表
In operating systems ... one may use a linked list to keep track of what processes are running and what processes are sleeping ... a process that is running and wants to sleep ... gets removed from the LinkedList that keeps track of running processes and once the sleep time is over adds it back to the active process LinkedList
Maybe newer OS are using some funky data structures ... linked lists can be used there
好吧,如果老师带学生去看卡通电影,但她找不到座位,她会要求学生记住下一个学生的地址(座位号)等等......这样她就不会回去的时候要面对麻烦!!!
well if a teacher took his students to a cartoon movie but she couldn't get the seats together, she'll ask students to remember the address(seat number) of next student and so on... so that she wouldn't have to face the trouble while going back!!!
链表的一个很好的例子是您的文本消息,其中消息的某个数据包可能被分为多个数据包。 每个数据包都包含一个密钥,该密钥连接到下一个密钥和第 n 个密钥,以形成包含密钥和数据的整个文本消息。
A good example of a linked list is your text message, wherein a certain packet a message may be divided into several packets. Each packet holds a key which connects to the next key and to the n-th key to make the whole text message wherein it contains the key and the data.
他确实要求提供一个实际的例子; 所以我会尝试一下:
假设您正在编写一个防火墙; 在此防火墙中,您有一个 IP 白名单和一个 IP 黑名单。
您知道您的 IP、您的工作 IP 和一些测试 IP 需要列入白名单。 因此,您将所有 IP 添加到白名单中。
现在,您还有一个应该阻止的已知 IP 列表。 因此,您将这些 IP 添加到黑名单中。
为什么要使用 LinkedList 呢?
He did ask for a practical example; so I'll give it a shot:
Lets say you are writing a firewall; in this firewall you have an IP whitelist and an IP blacklist.
You know that your IP, your jobs IP, and some testing IP's need to be whitelisted. So, you add all of the IP's to the whitelist.
Now, you also have a list of known IP's that should be blocked. So, you add those IPs to the blacklist.
Why might use LinkedList for this?
我认为没有一个很好的类比可以突出数组相对于数组的两个重要特征:1. 在当前项之后高效插入;2. 通过索引查找特定项效率低下。
没有这样的事情,因为通常人们不会处理需要插入或定位特定项目的大量项目。 例如,如果你有一袋沙子,那将是数亿粒沙子,但你不需要找到特定的沙子,而且沙子的顺序也不重要。
当您处理较小的馆藏时,您可以直观地找到所需的项目,或者,如果是图书馆中的书籍,您将拥有类似字典的组织。
最接近的类比是让一个盲人检查链接的物品,例如链环、项链上的珠子、火车车厢等。他可能正在寻找特定的物品或需要在当前物品之后插入物品。 最好补充一下,盲人可以非常快地穿过它们,例如每秒一百万颗珠子,但一次只能感觉到一个链接,而看不到整个链条或其中的一部分。
请注意,这个类比类似于双链表,我无法想到与单链表类似的类比,因为拥有物理连接意味着回溯的能力。
I don't think there is a good analogy that could highlight the two important characteristics as opposed to an array: 1. efficient to insert after current item and 2. inefficient to find a specific item by index.
There's nothing like that because normally people don't deal with very large number of items where you need to insert or locate specific items. For example, if you have a bag of sand, that would be hundreds of millions of grains, but you don't need to locate a specific grain, and the order of grains isn't important.
When you deal with smaller collections, you can locate the needed item visually, or, in case of books in a library, you will have a dictinary-like organization.
The closest analogy is having a blind man who goes through linked items like links of chain, beads on a necklace, train cars, etc. He may be looking for specific item or needing to insert an item after current one. It might be good to add that the blind man can go through them very quickly, e.g. one million beads per second, but can only feel one link at a time, and cannot see the whole chain or part of it.
Note that this analogy is similar to a double-linked list, I can't think of a similar analogy with singly linked one, because having a physical connection implies ability to backtrack.
一个很好的例子就是我认为你家庭的层次结构树,因为你与你的祖父母和曾祖父母有联系。 这就是我对链表的理解,但这基本上是我自己的看法。
A good example of this is I think the hierarchy tree of your family because you are linked to your grandparents and to your great grandparents. This is how I understand linked list tho its basically my own opinion.
我喜欢将循环链表想象成珍珠项链,每颗珍珠都包含一点数据。 您只需沿着字符串找到下一个数据珍珠,最终您会再次回到开头。
I like to think of a circular linked list like a pearl necklace, with each pearl containing a bit of data. You just follow the string to the next pearl of data, and eventually you end up at the beginning again.
链接列表就像康加舞线。 每个人都握住前面的人的臀部,然后由后面的人轮流握住自己的臀部,只有前面和后面的人除外。 将人员添加到线路中的唯一方法是找到正确的位置并解耦该连接,然后插入新的人员。
A linked list is like a conga line. Everyone holds the hips of the person in front of them and their hips are held in turn by the person to their rear, excepting only those in the front and the back. The only way to add people to the line is to find the right spot and decouple that connection, then insert the new person or people.
我假设您想要比书籍定义更具隐喻性的解释,而不是如何使用链接列表的示例。
链表有点像寻宝游戏。 您有一条线索,并且该线索有一个指向位置的指针以查找下一条线索。 所以你转到下一个地方并获取另一条数据和另一个指针。 想要在中间或最后得到一些东西,唯一的方法就是从头开始遵循这个列表(或者作弊;))
I'm assuming you want a more metaphorical explanation than the book definition, instead of examples of how you could use a linked list.
A linked list is kind of like a scavenger hunt. You have a clue, and that clue has a pointer to place to find the next clue. So you go to the next place and get another piece of data, and another pointer. To get something in the middle, or at the end, the only way to get to it is to follow this list from the beginning (or to cheat ;) )
现实世界中链表的实际示例是什么?
最简单、最直接的是火车。
火车车厢按特定顺序连接,以便以最有效的方式装卸、转运、下车和上车。
例如,Jiffy Mix 工厂需要糖、面粉、玉米粉等。拐弯处可能是一家需要氯、硫酸和氢气的造纸厂。
现在,我们可以停下火车,卸下每节车厢的货物,然后让火车继续行驶,但是当面粉从沉箱中吸出时,火车上的其他所有东西都必须静置,然后是糖等。
相反,车厢按顺序装载到火车上,以便可以将整个车厢拆下,然后火车的其余部分继续行驶。
火车尾部比中间部分更容易拆卸,并且比在一个地方拆卸几节车厢和在另一个地方拆卸几节车厢要容易得多。
但是,如果需要,您可以在列车中的任何位置插入和取出物品。
很像一个链接列表。
-亚当
What is a practical, real world example of the Linked List?
The simplest and most straightforward is a train.
Train cars are linked in a specific order so that they may be loaded, unloaded, transferred, dropped off, and picked up in the most efficient manner possible.
For instance, the Jiffy Mix plant needs sugar, flour, cornmeal, etc. Just around the bend might be a paper processing plant that needs chlorine, sulfuric acid, and hydrogen.
Now, we can stop the train, unload each car of its contents, then let the train go on, but then everything else on the train has to sit while flour is sucked out of the caisson, then the sugar, etc.
Instead, the cars are loaded on the train in order so that a whole chunk of it can be detached, and the remainder of the train moves on.
The end of the train is easier to detach than a portion in the middle, and vastly easier than detaching a few cars in one spot, and a few cars in another spot.
If needed, however, you can insert and remove items at any point in the train.
Much like a linked list.
-Adam
首先要理解的是,链表在概念上与数组相同。
唯一的区别在于各种操作的效率。 最重要的是:
因此,任何可用于数组的类比(飞机的所有引擎、购物清单上的所有物品……)也适用于链表,但出于效率考虑,可以适当地进行另一个类比
:数组将是书柜中的盒子。 当您从第 n 行移除盒子时,从 n+1 开始的所有盒子都需要向下移动一个架子(这样您就不会遇到麻烦的空架子)。
相反,链接列表将是项链。 当您发现您不再喜欢那颗蓝色宝石时,请将其从序列中取出并将所得的两端绑在一起。 无需穿过每颗珍珠并将其移开,这样您就可以修复项链。
First thing to understand is that a linked list is conceptually the same as an array.
The only difference is in the efficiency of various operations. Most importantly:
Thus any analogy that can be used for an array (all the engines of a plane, all the items on a shopping list...) also applies to a linked list, but the efficiency consideration could make it appropriate to make another analogy:
An array would be boxes in a bookcase. When you remove the box from from the n-th row, all boxes from n+1 up need to be moved one shelf down (so you don't have a troublesome empty shelf).
A linked list, conversely, would be a necklace. When you find you don't like that blue jewel anymore, take it out of the sequence and tie the resulting two ends together. No need to loop through each pearl and displace it just so you can fix your necklace.
在出纳员/收银员处排队等候...
一系列必须按顺序执行的订单。
任何 FIFO 结构都可以实现为链表。
Waiting line at a teller/cashier, etc...
A series of orders which must be executed in order.
Any FIFO structure can be implemented as a linked list.
现实生活中的例子:
**1)单链表 **
2)双向链表
3)循环链表
Real life example for:
**1) Singly linked list **
2) Doubly linked list
3) Circular linked list
我记得很多年前,在我的第一堂大学课程中,我想知道我会在哪里使用链接列表。 今天,我认为我所从事的项目没有一个是我没有使用过的,而且在很多地方都使用过。 这是一个非常基础的数据结构,相信我,它在现实世界中被大量使用。
例如:
现在对你来说似乎有点无用,但几年后,问自己同样的问题,你会发现自己很惊讶你曾经想知道它会用在哪里。
编辑:
我注意到您在一篇评论中询问了为什么指针很重要。 有人正确地回答说,指针对于链表的用户来说并不重要。 用户只需要一个包含事物列表的列表。 该列表如何“包含”该列表的内容对于用户来说并不重要。 指针是“如何”的一部分。 想象在地板上画一条线,通向出纳员。 人们需要站在那条线上才能到达柜员处。 该行是对链接列表使用的指针的类比(我承认,这有点夸张)。 出纳员排队的第一个人是名单的首位。 线路中紧随其后的人是列表中的下一个。 最后,队伍中的最后一个人是名单的末尾。
I remember, many years ago, in one of my first college classes, wondering where I would ever , ever use a linked list. Today, I don't think there is a single project I work on where I haven't used one, and in many places. It's an incredibly fundamental data structure, and believe me, it's used heavily in the real world.
For example:
It may seem slightly useless to you now, but a few years from now, ask yourself the same question, you'll find yourself surprised that you ever wondered where it would be used.
Edit:
I noticed in one of your comments you asked about why the pointer matters. Someone rightly answered that the pointer doesn't really matter to a user of a linked list. A user just wants a list that contains a, well, list of things. How that list "contains" that list of things doesn't really matter to the user. The pointer is part of that "how". Imagine a line, drawn on the floor, that leads to a teller. People need to be standing on that line to be able to get to the teller. That line is a (and I admit, this is a bit of a stretch) analogy for the pointer a linked list uses. The first person, at the teller, on the line, is the head of the list. The person directly behind them on the line is the next in the list. And finally, the last person in the line, on the line, is the tail of the list.
Blame 的方式是让一群软件工程师在项目中的不同模块上工作。
首先,GUI 人员因产品无法正常工作而受到指责。 他检查了代码,发现这不是他的错:API 搞砸了。 API 人员检查了他的代码:不是他的错,而是记录器模块的问题。 记录器模块人员现在责怪数据库人员,数据库人员又归咎于安装程序人员,后者又归咎......
The way Blame moves around a bunch of software engineers working on different modules in a project.
First, the GUI guy gets blamed for the product not working. He checks his code and sees it's not his fault: the API is screwing up. The API guy checks his code: not his fault, it's a problem with the logger module. Logger module guy now blames database guy, who blames installer guy, who blames...
你的 DNA 分子是双链表。
Your DNA molecules are double-linked lists.
一条链:
特别是滚子链:
链中的每个元素都与其后继和前驱相连。
A chain:
Especially the roller chain:
Each element of the chain is connected to its successor and predecessor.
如果您仔细想想,“链接”只是一种识别数据实例之间“下一个”、“上一个”、“子级”或“父级”关系的方法。因此,在现实世界的应用程序中您会发现各种各样的应用程序。 考虑一个简单的列表(例如杂货列表)作为基本链接列表。 但也要考虑一下我们可以放置图(在地图上绘制城市之间的距离、生物学中物种之间的相互作用)或树(组织中的层次结构或数据库索引中的数据,用于两个非常不同的示例)的用途。
If you think about it, a "Link" is simply a way of identifying a "Next", "Previous", "Child" or "Parent" relationship among data instances. So, among real world applications you'll find a broad variety of applications. Think of a simple List (e.g. Grocery List) for basic Linked Lists. But consider too the uses to which we can place Graphs (plotting distances between cities on a map, interactions among species in biology) or Trees (hierarchies in an organization or data in an index of a database for two very diverse examples).
链表可用于实现队列。 现实生活中典型的例子是收银员排队。
链表还可用于实现堆栈。 真实的圆锥形例子是自助餐厅的盘子分配器之一,它将顶盘从堆叠的顶部拉下来。
A linked list can be used to implement a queue. The canonical real life example would be a line for a cashier.
A linked list can also be used to implement a stack. The cononical real ife example would be one of those plate dispensers at a buffet restaurant where pull the top plate off the top of the stack.
在一般情况下,链表是您将遇到的最有用的东西之一。
现实世界的例子:
一群人在排队等待
某种东西或其他 - 一种特殊的东西
LL的叫一个“队列”。
你瓷器里的一堆盘子
Cabinet——一种特殊的 LL,称为
一个“堆栈”。
“取一个数字”行(其中
数字必须重新开始
“1”在某些时候) - 一种特殊的
LL 称为“循环队列”。
一般来说,我喜欢对几乎所有链接的数据结构使用的比喻是一副纸牌。 几乎任何你可以用链表做的事情,你都可以使用一副卡片来可视化。 这对于向您自己展示一些更深奥的排序算法中发生的情况特别方便。
我个人最喜欢的: Bogosort = 玩 52 张牌拾取,直到你的牌组排序完毕。 :-)
In the general case, linked lists are one of the most devilishly useful things you will encounter.
Real world examples:
A bunch of people waiting in line for
something or other - a special kind
of LL called a "queue".
The stack of dishes in your china
cabinet - a special kind of LL called
a "stack".
The "take a number" lines (where the
numbers have to start over again at
"1" at some point) - a special kind of
LL called a "circular queue".
Generally the metaphor I like to use for almost all linked data structures though is a deck of cards. Just about anything you can do with linked lists, you can use a deck of cards to visualise. This is particularly handy to show yourself what is going on in some of the more esoteric sorting algorithms.
My personal favorite: Bogosort = play 52 card pickup until your deck is sorted. :-)
人脑可以是单链表的一个很好的例子。 在背诵学习某些东西的初始阶段,自然的过程是将一个项目链接到下一个项目。 这是一种潜意识的行为。 让我们以抢劫华兹华斯的孤独收割者的8行为例:
我们的思维并不像促进随机访问的数组那样运作良好。 如果你问那个人最后一行是什么,他会更难说出来。 他必须从一号线到达那里。 如果你问他第五行是什么,那就更难了。
同时如果你给他一个指示,他就会往前走。 好吧,从
自己收割和唱歌开始;
? 现在变得更容易了。 如果你能给他两句台词就更容易了,她独自切割并捆扎谷物,唱着忧郁的曲调;
因为他的流畅性更好。 同样,如果你什么都不给他,他将不得不从头开始获取台词。 这是经典的链表。这个类比应该没有什么异常之处,可能不太合适,但这在某种程度上解释了链表的工作原理。 一旦你变得有点熟练或从里到外了解这首诗,链表就会滚动(大脑)到一个哈希表或数组中,这有助于 O(1) 查找,你可以从任何地方挑选诗行。
Human brain can be a good example of singly linked list. In the initial stages of learning something by heart, the natural process is to link one item to next. It's a subconscious act. Let's take an example of mugging up 8 lines of Wordsworth's Solitary Reaper:
Our mind doesn't work well like an array that facilitates random access. If you ask the guy what's the last line, it will be harder for him to tell. He will have to go from line one to reach there. It's even harder if you ask him what's the fifth line.
At the same time if you give him a pointer, he will go forward. Ok start from
Reaping and singing by herself;
?. It becomes easier now. It's even easier if you could give him two lines,Alone she cuts and binds the grain, And sings a melancholy strain;
because he gets the flow better. Similarly, if you give him nothing at all, he will have to start from the start to get the lines. This is classic linked list.There should be few anomalies in the analogy which might not fit well, but this somewhat explains how linked list works. Once you become somewhat proficient or know the poem inside-out, the linked list rolls (brain) into a hash table or array which facilitates O(1) lookup where you will be able to pick the lines from anywhere.
单链表的一些例子。
双链表的一些例子。
Some example of single linked list.
Some example of double linked list.
我对这个问题的第一反应是“环顾四周!这东西到处都是!” 但想了一会儿,我想不出任何不是人为的例子。
链表的概念是一个复合概念,即two-fer。 您有列表的概念,这没问题。 例如,杂货清单。 然后你就到了链接部分。 一个杂货项目不知道下一个杂货项目,因此模型崩溃了。
我认为您难以找到现实世界的示例的原因是链接部分是一个编程工件,一个实现细节。 以编程方式实现列表的方法有很多,其中一种好的方法是让每个列表项了解其邻居。 另一种方法是使用一个 List 对象来跟踪项目及其顺序。 这就是现实生活中大多数列表的工作方式。 在上面的示例中,杂货清单的 List 对象将是其所写的纸张(或其他任何东西)。
也许从总体上考虑列表并将链接列表视为列表的特定实现更有用。
My first reaction to this question was "Look around! This stuff is everywhere!" But after thinking about it for a bit, I couldn't think of any example that isn't contrived.
The concept of a linked list is a compound concept, a two-fer. You have the notion of a list, which is no problem. A grocery list, for example. Then you get to the link part. One grocery item doesn't know about the next grocery item, so the model breaks down.
I think that the reason you are having trouble with finding a real world eample is that the link part is a programming artifact, an implementation detail. There are many ways to implement lists programatically and one good way is to have each list item know about its neighbors. Another way is to have a List object that keeps track of the items and their order. This is how most lists work in real life. In the example above, the List object for the grocery list would be the paper (or whatever) it's written on.
Maybe it's more useful to think about lists in general and view linked lists as just a specific implementation of a list.
双向链表的最佳且直接的示例是 Train!
这里每个教练连接到其上一个和下一个 Coach(除了第一个和最后一个)
在编程方面,将 Coach 主体视为数据(值)节点,将连接器视为参考节点。
Best and straight forward example of doubly linked list is Train!
Here Each coach is connected to its previous and next coach(Except first and last)
In terms of programming consider coach body as data(value) node and connector as reference node.
在 .NET BCL 中,
System.Exception
类有一个名为InnerException
的属性,它指向另一个异常,否则为null
。 这形成了一个链接列表。在
System.Type
中,BaseType
属性以相同的方式指向另一个类型。In the .NET BCL, the class
System.Exception
has a property calledInnerException
, which points to another exception or else isnull
. This forms a linked list.In
System.Type
, theBaseType
property points to another type in the same way.在 make 程序中,您经常会发现需要构建的特定文件的依赖项列表被定义为指向其他文件的指针的链接列表,这些文件也需要构建并依次具有依赖项在链接列表中。
Inside the
make
program, you will often find that the dependency lists for a particular file that needs to be built are defined as linked lists of pointers to other files which also need to be built and in turn have dependencies in linked lists.