First time with linked lists - how do I name objects for insertion

一个人想着一个人 提交于 2019-12-12 04:33:38

问题


Ok,

Dumb question time:

Usually with an array I have an object name: object[index] ...and if I have many of them then the index is what distinguishes each object from each other, hopefully, and usually in my case the index has a connection of to the reality of whatever the object is representing so I don't have to go hunting - the third one is the third one...

Now I have a job that requires a linked list as kind of queue (part of an LRU cache) - I just hit a question:

I'm about to declare the first object and add it to the linked list - but what do I call it ?

object ? ...and I have lots of these somehow ?

object1 ? ...if this is the way, then how do I get that '1' there (and then '2' and so on)

I'm guessing the real solution is either really basic and I'll slap myself and/or pointers are involved ?

At the moment I'm just working out the project in terms of major algorithms in pseudoCode and every day go deeper into details. I'm yet to really learn C++ and am coming from a little Java course with and some basic ADT topics, but have no experience in practicalities. Any help really appreciated.

Thanks much!


回答1:


Linked list objects are called nodes, the first one would be head. Yes pointers are involved :) More info http://www.algorithmist.com/index.php/Linked_List



来源:https://stackoverflow.com/questions/13784732/first-time-with-linked-lists-how-do-i-name-objects-for-insertion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!