Question

When using the overloads which directly accept your data (i.e. linkedList.AddFirst(myData) and linkedList.RemoveFirst()), does .NET internally recycle its link nodes?

Or would this need to be accomplished manually with a Queue?

Was it helpful?

Solution

No, nodes are not recycled.

As you can see from the reference source, new nodes are created when new data is added.

public LinkedListNode<T> AddFirst(T value) {
    LinkedListNode<T> result = new LinkedListNode<T>(this, value);

    ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top