什么是链接列表的实际,现实世界的例子? [英] What is a practical, real world example of the Linked List?

查看:203
本文介绍了什么是链接列表的实际,现实世界的例子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解链接列表的定义,但是如何表示和关联一个常见的概念或项目?

I understand the definition of a Linked List, but how can it be represented and related to a common concept or item?

例如,OOP中的composition(EDIT:最初称为inheritance)可以与汽车相关。在现实生活中的所有(大多数)汽车是基本上相同的东西;一个汽车有一个Engine,你可以启动()它,可以让汽车去(),stop()等等。汽车通常具有最大乘客容量,但是在公共汽车和运动跑车之间将不同,两者都是汽车。

For example, composition ( 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.

推荐答案

链接列表类似于 conga line 。每个人都在他们面前握着人的臀部,他们的臀部依次由人在他们的后面,除了前面和后面的人。添加人员的唯一方法是找到正确的位置并解除连接,然后插入新的人员。

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.

这篇关于什么是链接列表的实际,现实世界的例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆