链接列表中的链接项 [英] Link items in Linked List

查看:108
本文介绍了链接列表中的链接项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS2010.在我的应用程序中,我有一个链表,其中包含一些整数.我希望能够将列表中的最后一项链接到列表中的第一项,以便当我遍历列表时,它应连续运行,直到被事件停止为止(例如圆周运动,它一直在继续)

我知道列表中的最后一个项目的头部应指向列表中第一个项目的尾部.我该如何实现?

I am using VS 2010. In my application, I have a linked list, containing a few integers. I want to be able to link the last item in the list to the first item in the list, so that when I loop through the list, it should run continuously until stopped by event (like a circular motion, it just keeps on going)

I know that with the last item in the list, the head should point to the first item''s tail in the list. How do I achieve this? Any articles or help would be appreciated

推荐答案

您正在寻找的是一个循环链表.
http://navaneethkn.wordpress.com/2009/08/18/circular-linked-list / [ ^ ]是一个很好的资源,应该可以为您提供帮助.
What you are looking for is a circular linked list.
http://navaneethkn.wordpress.com/2009/08/18/circular-linked-list/[^] is a very good resource and should help you out.


尝试:
lastItem.Next = head;

这将为您提供参考列表中的第一个项目(来自head),并将其分配为最后一个项目的下一个项目.

That gets the reference for the first item in the list (from head) and assigns it as the next item for the last item.


这篇关于链接列表中的链接项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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