| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| C-Sharp Programming Post questions, answers, and comments about C#. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need a bit of help with Link-list
I basically need help using a link-list to implement a certain number of strings, I would like each element to be link to the next node. so far I have:
Class ListNode { string x; ListNode Next; } Class List { ListNode First; } That will take care of linking the nodes but i need guidance on where to go from here. Is link-list the way to go, how should I create a class to insert the strings? |
|
#2
|
|||
|
|||
|
Re: Need a bit of help with Link-list
Hi. Why do actually need to link the items? What do you intend to do with the list? That would determine whether or not a linkd list is the way to go.
|
|
#3
|
|||
|
|||
|
Re: Need a bit of help with Link-list
Eventually I want to insert or remove elements in a list without impacting all the elements at once. I think using Linklist will work the best for the situation, just unsure about the implementation of x number of strings, while each element is connected to the next node.
Afterwards I could find items and replace them with ease LinkedListNode<string> node = linked.Find("item"); linked.AddAfter(node, "inserted"); But that would be after the strings are implementated. |
|
#4
|
|||
|
|||
|
Re: Need a bit of help with Link-list
Quote:
|
|
#5
|
|||
|
|||
|
Re: Need a bit of help with Link-list
Okay, I suppose an List will work out nicely. but if I wanted to implement some string and each element has a link to the next node, is this still possible with List? I can't figure out the implementation of this implementation class, heh.
|
|
#6
|
|||
|
|||
|
Re: Need a bit of help with Link-list
If you want to have elements that are linked to each other (e.g. you want to model some kind of hierarchy) linked list is the obvious choice. If you need the linked list the .NET framework has one out of the box. It should just as easy to use as the List<T>. Check it out...Linked List
|
|
#7
|
|||
|
|||
|
Re: Need a bit of help with Link-list
Thank you! this is excellent news. I'm not sure how I will incorporate my other classes, not too familiar with Next and First statements but hopefully i'll figure it out! thank you
|
|
#8
|
|||
|
|||
|
Re: Need a bit of help with Link-list
hmm, still having problems figuring out how to implement the other classes...
|
|
#9
|
||||
|
||||
|
Re: Need a bit of help with Link-list
Can you explain why each element needs to know the next element in the list. Isn't this the job of a container rather than an element? Are you solving a real world problem, or is this a student assignment? If the latter, can you explain more in detail what you are trying to solve?
|
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|