Quickie Linked List Deallocation question.

This is a discussion on Quickie Linked List Deallocation question. within the C# Programming forums, part of the General Programming Boards category; Okie, just started using C# a few days ago and it seems relatively easy although I wanted to get one ...

That's right. .Net's garbage collection is pretty good; when you can no longer access a piece of memory, it is marked for deletion. You don't even have to worry about circular references. The only time you have to worry about freeing resources is when you have unmanaged resources. Then you should implement IDisposable using the IDisposable pattern mentioned on MSDN.

Just wondering, are you implementing a linked list class? If so, why not just use the generic LinkedList class?

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

Just wondering, are you implementing a linked list class? If so, why not just use the generic LinkedList class?

I've got a bad habit of creating my own linked structures for my personalized situation instead of using the provided one since I was forced in school to write my own for learning purposes. Don't know why.. guess its a habit I should break.

I've got a bad habit of creating my own linked structures for my personalized situation instead of using the provided one since I was forced in school to write my own for learning purposes. Don't know why.. guess its a habit I should break.

And I applaud you for that. Many people recommend learners use a feature already provided in the language but, I think that is a bad idea most of the time. The more things you do on your own, the more you learn (reinventing the wheel ) . It's that simple. After you learn, then I agree that you should use what the language provides over your alternative.

Aye, I agree that it's useful as a learning construct. However, it should usually be abandoned in other code. The data types provided by the library are implemented so that they work together and rigorously tested. This makes it a pretty dependable library to work with.

As another learning exercise, you might try implementing all of the interfaces from LinkedList<T> on your custom linked list class. If your class is generic, that'd be ICollection<T>, ICollection, ISerializable, and IDeserializationCallback. If your class isn't generic, you can leave off ICollection<T>. This is useful because it gives you the experience of implementing interfaces (which isn't always as straightforward as it seems), and you can now use your custom linked list class where ever something was expecting one of those interfaces.

If you really want to exercise those coding skills, write a generic binary tree data type for .Net, implementing IDictionary<Tkey,Tvalue>, ISerializable, and IDeserializationCallback. I was surprised that the standard assembilies didn't come with one.

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein