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?

Était-ce utile?

La 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);

    ...
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top