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);
...
}
题
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?
解决方案
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);
...
}