I dont understand Linked Lists

Started by
7 comments, last by Star2 21 years, 3 months ago
So, from what I get, Linked Lists are something you create yourself ?? Its not a built-in "function" in C++ right? Cuz as of what I saw in a code that sorted numbers, it was all coded customly. You cant define a linked list like a function/class right? Thanks for your help.
Advertisement
A linked list isn''t really a function or anything like that. The idea of a "linked list" isn''t something that is defined like an int. It''s a conceptual thing that you''re free to implement however you want. Basically the idea is that you have a class which holds some data. Part of the data that that class holds is a pointer to the next instance of the class. In this way, you have a list of instances of classes "linked together." Their might be some linked lists defined in the libraries that come with your compiler, if not, it isn''t too terribly difficult to write one yourself. If you''d like some instruction on how to do that, you could probably find a lot of tutorials or something on the web. If you have no luck there, I could send you some info. Good luck.
Thanks for the help,

I know how to make them, but I was just confused over that I had to write it myself and still it had a name, but I get it now, its just a concept.

Now I understand.

linked lists are implemented for you in the stl --i believe as a template class.
There are classes you can use to make it quicker, those are bundled and called STL. Standard Template Library, that is. So thesse are pretty standard C++. But people like me, ust make there own linked lists. The choice is all yours!

.lick
quote:Original post by Anonymous Poster
Their might be some linked lists defined in the libraries that come with your compiler, if not, it isn''t too terribly difficult to write one yourself.

If you are using C++, there is no "might" about it. All conforming C++ compilers must ship with an implementation of std::list.


"The fact that a believer is happier than a skeptic is no more to the point than the fact that a drunken man is happier than a sober one." -- George Bernhard Shaw
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
quote:Original post by Pipo DeClown
But people like me, ust make there own linked lists.

What kind of people might that be?


"The fact that a believer is happier than a skeptic is no more to the point than the fact that a drunken man is happier than a sober one." -- George Bernhard Shaw
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Arild Fines, don''t get me started. I spent a LONG time in work debugging someone else''s sorted linked list written in C.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Think of a linked list as an array which holds pointers to objects in memory. The difference between an array declared like this:

CMyObect* SomeObject[12]; //12 pointers to CMyObject''s

and a linked list is this: You can add and change the number of objects in a linked list, but the array is definitly going to be (in this example) 12 objects, unless you delete it and reassign it. the linked list can have 0 entries or 100, it doesn''t matter. You don''t need to delete the linked list to change the number of entries; It can change size dynamically.

A linked list is a data structure. If you don''t understand what a linked list is or how to implement it, then you won''t understand BSP trees or Octrees. These are data structures as well, but they form a basis on linked lists. I wouldn''t use the STL until you fully understand how to create a linked list yourself.
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.

This topic is closed to new replies.

Advertisement